Skip to content

Commit 8c700f7

Browse files
Merge pull request #170 from refactorfirst/#152-handle-generated-classes
#152 Handling generated classes
2 parents 9ddd7f2 + 796dcf4 commit 8c700f7

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

change-proneness-ranker/src/main/java/org/hjug/git/GitLogReader.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,14 @@ public ScmLogInfo fileLog(String path) throws GitAPIException, IOException {
7878
}
7979

8080
// based on https://stackoverflow.com/a/59274329/346247
81-
int mostRecentCommit = git.log()
82-
.add(branchId)
83-
.addPath(path)
84-
.setMaxCount(1)
85-
.call()
86-
.iterator()
87-
.next()
88-
.getCommitTime();
81+
Iterator<RevCommit> iterator =
82+
git.log().add(branchId).addPath(path).setMaxCount(1).call().iterator();
83+
84+
if (!iterator.hasNext()) {
85+
return new ScmLogInfo(path, null, earliestCommit, earliestCommit, commitCount);
86+
}
87+
88+
int mostRecentCommit = iterator.next().getCommitTime();
8989

9090
return new ScmLogInfo(path, null, earliestCommit, mostRecentCommit, commitCount);
9191
}

0 commit comments

Comments
 (0)