Skip to content

Commit

Permalink
Retrieves data from the developers that make the commits (name, email,
Browse files Browse the repository at this point in the history
etc)
  • Loading branch information
martinezmatias committed Sep 24, 2020
1 parent de22408 commit 6779d8d
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 0 deletions.
46 changes: 46 additions & 0 deletions src/main/java/fr/inria/coming/core/engine/git/CommitGit.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,18 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

import org.eclipse.jgit.diff.DiffEntry;
import org.eclipse.jgit.diff.DiffEntry.ChangeType;
import org.eclipse.jgit.diff.DiffFormatter;
import org.eclipse.jgit.diff.RawTextComparator;
import org.eclipse.jgit.errors.IncorrectObjectTypeException;
import org.eclipse.jgit.errors.MissingObjectException;
import org.eclipse.jgit.lib.Constants;
import org.eclipse.jgit.lib.ObjectId;
import org.eclipse.jgit.lib.PersonIdent;
import org.eclipse.jgit.lib.Ref;
import org.eclipse.jgit.lib.Repository;
import org.eclipse.jgit.revwalk.RevCommit;
import org.eclipse.jgit.revwalk.RevWalk;
Expand Down Expand Up @@ -157,9 +160,52 @@ public List<FileCommit> getFileCommits(String extension) {

@Override
public String getName() {

return this.revCommit.getName();
}

@Override
public List<String> getParents() {

List<String> parents = new ArrayList();
for (RevCommit rc : this.revCommit.getParents()) {
parents.add(rc.getName());
}

return parents;
}

@Override
public List<String> getBranches() {

List<String> branches = new ArrayList();
// https://www.eclipse.org/forums/index.php/t/280339/
RevWalk walk = new RevWalk(repo.getRepository());
for (Map.Entry<String, Ref> e : repo.getRepository().getAllRefs().entrySet())

if (e.getKey().startsWith(Constants.R_HEADS) || e.getKey().startsWith(Constants.R_REMOTES))
try {
RevCommit parseCommit = walk.parseCommit(e.getValue().getObjectId());
RevCommit base = walk.parseCommit(this.revCommit.toObjectId());

if (walk.isMergedInto(base, parseCommit)) {
branches.add(e.getValue().getName());
}

} catch (Exception e1) {

e1.printStackTrace();
}

return branches;
}

@Override
public PersonIdent getAuthorInfo() {
return this.revCommit.getAuthorIdent();

}

@Override
public boolean containsJavaFile() {
List<FileCommit> javaFiles = getJavaFileCommits();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import java.util.List;

import org.eclipse.jgit.lib.PersonIdent;

import fr.inria.coming.changeminer.entity.IRevision;

public interface Commit extends IRevision {
Expand Down Expand Up @@ -34,4 +36,10 @@ public interface Commit extends IRevision {

public String getRevDate();

public List<String> getParents();

public List<String> getBranches();

public PersonIdent getAuthorInfo();

}

0 comments on commit 6779d8d

Please sign in to comment.