use of com.intellij.vcs.log.CommitId in project intellij-community by JetBrains.
the class GithubOpenInBrowserAction method getDataFromLog.
@Nullable
private static CommitData getDataFromLog(AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
VcsLog log = e.getData(VcsLogDataKeys.VCS_LOG);
if (project == null || log == null)
return null;
List<CommitId> selectedCommits = log.getSelectedCommits();
if (selectedCommits.size() != 1)
return null;
CommitId commit = ContainerUtil.getFirstItem(selectedCommits);
if (commit == null)
return null;
GitRepository repository = GitUtil.getRepositoryManager(project).getRepositoryForRoot(commit.getRoot());
if (repository == null || !GithubUtil.isRepositoryOnGitHub(repository))
return null;
return new CommitData(project, repository, commit.getHash().asString());
}
Aggregations