diff --git a/change-proneness-ranker/src/main/java/org/hjug/git/GitLogReader.java b/change-proneness-ranker/src/main/java/org/hjug/git/GitLogReader.java index c82c49b..18d8e37 100644 --- a/change-proneness-ranker/src/main/java/org/hjug/git/GitLogReader.java +++ b/change-proneness-ranker/src/main/java/org/hjug/git/GitLogReader.java @@ -78,14 +78,14 @@ public ScmLogInfo fileLog(String path) throws GitAPIException, IOException { } // based on https://stackoverflow.com/a/59274329/346247 - int mostRecentCommit = git.log() - .add(branchId) - .addPath(path) - .setMaxCount(1) - .call() - .iterator() - .next() - .getCommitTime(); + Iterator iterator = + git.log().add(branchId).addPath(path).setMaxCount(1).call().iterator(); + + if (!iterator.hasNext()) { + return new ScmLogInfo(path, null, earliestCommit, earliestCommit, commitCount); + } + + int mostRecentCommit = iterator.next().getCommitTime(); return new ScmLogInfo(path, null, earliestCommit, mostRecentCommit, commitCount); }