-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding Gitective [1] as a dependency and creating the class that will be
responsible for the local Git repository analysis within Groundhog. Starting with non-parameterized commit extraction and extraction of commits from a given user. Nothing finished just yet. Code in main package only present for current debugging and testing purposes, once the commit message extraction is done it will be moved to the groundhog-case-study [2] project. [1]: https://github.com/kevinsawicki/gitective [2]: github.com/gustavopinto/groundhog-case-study Related to #55 and #60
- Loading branch information
Rodrigo Alves
committed
Sep 5, 2013
1 parent
6177b1d
commit ea3e82d
Showing
5 changed files
with
112 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
84 changes: 84 additions & 0 deletions
84
src/java/main/br/ufpe/cin/groundhog/extractor/GitCommitExtractor.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
package br.ufpe.cin.groundhog.extractor; | ||
|
||
import java.io.File; | ||
import java.io.IOException; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
import br.ufpe.cin.groundhog.Commit; | ||
import br.ufpe.cin.groundhog.User; | ||
|
||
import org.eclipse.jgit.lib.PersonIdent; | ||
import org.eclipse.jgit.lib.Repository; | ||
import org.eclipse.jgit.revwalk.RevCommit; | ||
import org.eclipse.jgit.revwalk.RevWalk; | ||
import org.eclipse.jgit.storage.file.FileRepositoryBuilder; | ||
import org.gitective.core.CommitFinder; | ||
import org.gitective.core.filter.commit.AndCommitFilter; | ||
import org.gitective.core.filter.commit.AuthorFilter; | ||
import org.gitective.core.filter.commit.CommitCountFilter; | ||
import org.gitective.core.filter.commit.CommitListFilter; | ||
|
||
/** | ||
* Extract Commit data from Git repositories | ||
* @author Rodrigo Alves | ||
* | ||
*/ | ||
public class GitCommitExtractor { | ||
private CommitCountFilter commits; | ||
|
||
public GitCommitExtractor() { | ||
this.commits = new CommitCountFilter(); | ||
} | ||
|
||
/** | ||
* | ||
* @param project | ||
* @return | ||
* @throws IOException | ||
*/ | ||
public List<Commit> extractCommits(File project) throws IOException { | ||
List<Commit> commits = new ArrayList<>(); | ||
String path = project.getAbsolutePath(); | ||
|
||
CommitFinder finder = new CommitFinder(path); | ||
FileRepositoryBuilder builder = new FileRepositoryBuilder(); | ||
Repository repository = builder.setGitDir(new File(path)).readEnvironment() | ||
.findGitDir() | ||
.build(); | ||
|
||
CommitListFilter list = new CommitListFilter(); | ||
|
||
for (RevCommit rev : list.getCommits()){ | ||
System.out.println(rev.getName()); | ||
System.out.println(rev.getAuthorIdent().getName()); | ||
System.out.println(rev.getShortMessage()); | ||
} | ||
|
||
return commits; | ||
} | ||
|
||
/** | ||
* Extracts only the commits from a given {@link User} | ||
* TODO: implement this method | ||
* @return a {@link List} of {@link Commit} objects | ||
* @throws IOException | ||
*/ | ||
public List<Commit> extractCommitFromUser(User user, File project) throws IOException { | ||
List<Commit> commits = new ArrayList<>(); | ||
|
||
String path = project.getAbsolutePath(); | ||
|
||
CommitFinder finder = new CommitFinder(path); | ||
FileRepositoryBuilder builder = new FileRepositoryBuilder(); | ||
Repository repository = builder.setGitDir(new File(path)).readEnvironment() | ||
.findGitDir() | ||
.build(); | ||
|
||
CommitListFilter list = new CommitListFilter(); | ||
AndCommitFilter filters = new AndCommitFilter(); | ||
PersonIdent author = new PersonIdent(user.getName(), user.getEmail()); | ||
|
||
filters.add(new AuthorFilter(author)); | ||
return commits; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters