Skip to content

Commit

Permalink
Merge pull request #812 from jenkinsci/recover-on-errors
Browse files Browse the repository at this point in the history
[JENKINS-73524] When analyzing git results, log and ignore exceptions
  • Loading branch information
uhafner authored Aug 19, 2024
2 parents fed3b8e + 42dd1d3 commit 0e26ccf
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import org.apache.commons.lang3.StringUtils;
import org.eclipse.jgit.api.Git;
Expand Down Expand Up @@ -62,11 +63,11 @@ private CommitDiffItem createFromRevCommit(final RevCommit newCommit) {
private String getAuthor(final RevCommit commit) {
PersonIdent author = commit.getAuthorIdent();
if (author != null) {
return StringUtils.defaultString(author.getEmailAddress(), author.getName());
return Objects.toString(author.getEmailAddress(), author.getName());
}
PersonIdent committer = commit.getCommitterIdent();
if (committer != null) {
return StringUtils.defaultString(committer.getEmailAddress(), committer.getName());
return Objects.toString(committer.getEmailAddress(), committer.getName());
}
return StringUtils.EMPTY;
}
Expand Down Expand Up @@ -102,5 +103,10 @@ static AbstractTreeIterator createTreeIteratorFor(final String commitId, final R
walk.dispose();
return treeParser;
}
catch (IOException e) {
logger.logError("Could not create tree iterator for commit ID " + commitId, e);

return new EmptyTreeIterator();
}
}
}

0 comments on commit 0e26ccf

Please sign in to comment.