public Optional<CommitDetails> getCommitDetails(String githubRepo, String sha) {
try {
logger.info("Getting commit details for sha {} on url {}", sha, githubRepo);
GHCommit commit = gitHub.getRepository(githubRepo).getCommit(sha);
GHUser author = commit.getAuthor();
String committerName = (author == null) ? null : author.getName();
if (committerName == null || committerName.isEmpty()) {
committerName = author.getLogin();
}
CommitDetails commitDetails = new CommitDetails(sha, commit.getHtmlUrl().toString(),
commit.getCommitShortInfo().getMessage(), commit.getCommitDate(), commit.getLastStatus(),
author.getAvatarUrl(), committerName);
return Optional.of(commitDetails);
} catch (IOException e) {
logger.warn("Could not get commit details from Github!", e);
return Optional.empty();
}
}