Java Code Examples for org.eclipse.jgit.revwalk.RevWalk#iterator()

The following examples show how to use org.eclipse.jgit.revwalk.RevWalk#iterator() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: APIDiff.java    From apidiff with MIT License 6 votes vote down vote up
@Override
public Result detectChangeAllHistory(String branch, List<Classifier> classifiers) throws Exception {
	Result result = new Result();
	GitService service = new GitServiceImpl();
	Repository repository = service.openRepositoryAndCloneIfNotExists(this.path, this.nameProject, this.url);
	RevWalk revWalk = service.createAllRevsWalk(repository, branch);
	//Commits.
	Iterator<RevCommit> i = revWalk.iterator();
	while(i.hasNext()){
		RevCommit currentCommit = i.next();
		for(Classifier classifierAPI: classifiers){
			Result resultByClassifier = this.diffCommit(currentCommit, repository, this.nameProject, classifierAPI);
			result.getChangeType().addAll(resultByClassifier.getChangeType());
			result.getChangeMethod().addAll(resultByClassifier.getChangeMethod());
			result.getChangeField().addAll(resultByClassifier.getChangeField());
		}
	}
	this.logger.info("Finished processing.");
	return result;
}
 
Example 2
Source File: APIDiff.java    From apidiff with MIT License 6 votes vote down vote up
@Override
public Result fetchAndDetectChange(List<Classifier> classifiers) {
	Result result = new Result();
	try {
		GitService service = new GitServiceImpl();
		Repository repository = service.openRepositoryAndCloneIfNotExists(this.path, this.nameProject, this.url);
		RevWalk revWalk = service.fetchAndCreateNewRevsWalk(repository, null);
		//Commits.
		Iterator<RevCommit> i = revWalk.iterator();
		while(i.hasNext()){
			RevCommit currentCommit = i.next();
			for(Classifier classifierAPI : classifiers){
				Result resultByClassifier = this.diffCommit(currentCommit, repository, this.nameProject, classifierAPI);
				result.getChangeType().addAll(resultByClassifier.getChangeType());
				result.getChangeMethod().addAll(resultByClassifier.getChangeMethod());
				result.getChangeField().addAll(resultByClassifier.getChangeField());
			}
		}
	} catch (Exception e) {
		this.logger.error("Error in calculating commit diff ", e);
	}

	this.logger.info("Finished processing.");
	return result;
}