private void diffChange(Project project, ChangeInfo changeInfo) {
Optional<GitRepository> gitRepositoryOptional = gerritGitUtil.getRepositoryForGerritProject(project, changeInfo.project);
if (!gitRepositoryOptional.isPresent()) {
NotificationBuilder notification = new NotificationBuilder(project, "Error",
String.format("No repository found for Gerrit project: '%s'.", changeInfo.project));
notificationService.notifyError(notification);
return;
}
GitRepository gitRepository = gitRepositoryOptional.get();
final String branchName = "FETCH_HEAD";
GitLocalBranch currentBranch = gitRepository.getCurrentBranch();
final String currentBranchName;
if (currentBranch != null) {
currentBranchName = currentBranch.getFullName();
} else {
currentBranchName = gitRepository.getCurrentRevision();
}
assert currentBranchName != null : "Current branch is neither a named branch nor a revision";
GitCommitCompareInfo compareInfo = gerritGitUtil.loadCommitsToCompare(
Collections.singletonList(gitRepository), branchName, project);
new GitCompareBranchesDialog(project, branchName, currentBranchName, compareInfo, gitRepository).show();
}