Skip to content

Commit

Permalink
Fix for issue #835
Browse files Browse the repository at this point in the history
createRevsWalkBetweenCommits() includes the parent of the specified start commit, so that we can obtain refactorings for the start commit
  • Loading branch information
tsantalis committed Dec 24, 2024
1 parent acca712 commit e056cff
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/org/refactoringminer/util/GitServiceImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,18 @@ public Iterable<RevCommit> createRevsWalkBetweenCommits(Repository repository, S
ObjectId from = repository.resolve(startCommitId);
ObjectId to = repository.resolve(endCommitId);
try (Git git = new Git(repository)) {
List<RevCommit> revCommits = StreamSupport.stream(git.log().addRange(from, to).call()
Iterable<RevCommit> iterable = git.log().add(from).call();
RevCommit parentOfStartCommit = null;
for(RevCommit commit : iterable) {
if(commit.getId().getName().startsWith(startCommitId)) {
if(commit.getParentCount() >= 1) {
parentOfStartCommit = commit.getParent(0);
break;
}
}
}
ObjectId since = parentOfStartCommit != null ? parentOfStartCommit.getId() : from;
List<RevCommit> revCommits = StreamSupport.stream(git.log().addRange(since, to).call()
.spliterator(), false)
.filter(r -> r.getParentCount() == 1)
.collect(Collectors.toList());
Expand Down

0 comments on commit e056cff

Please sign in to comment.