Search in sources :

Example 11 with CommitId

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());
}
Also used : Project(com.intellij.openapi.project.Project) GitRepository(git4idea.repo.GitRepository) CommitId(com.intellij.vcs.log.CommitId) VcsLog(com.intellij.vcs.log.VcsLog) Nullable(org.jetbrains.annotations.Nullable)

Aggregations

CommitId (com.intellij.vcs.log.CommitId)11 Project (com.intellij.openapi.project.Project)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 VcsLog (com.intellij.vcs.log.VcsLog)4 FileHistoryUi (com.intellij.vcs.log.history.FileHistoryUi)3 List (java.util.List)3 NotNull (org.jetbrains.annotations.NotNull)3 FilePath (com.intellij.openapi.vcs.FilePath)1 ShowDiffContext (com.intellij.openapi.vcs.changes.actions.diff.ShowDiffContext)1 VcsFileRevision (com.intellij.openapi.vcs.history.VcsFileRevision)1 MultiMap (com.intellij.util.containers.MultiMap)1 Hash (com.intellij.vcs.log.Hash)1 VcsFullCommitDetails (com.intellij.vcs.log.VcsFullCommitDetails)1 VcsLogProvider (com.intellij.vcs.log.VcsLogProvider)1 VcsShortCommitDetails (com.intellij.vcs.log.VcsShortCommitDetails)1 LoadingDetails (com.intellij.vcs.log.data.LoadingDetails)1 GitRepository (git4idea.repo.GitRepository)1 TIntIntHashMap (gnu.trove.TIntIntHashMap)1 TIntObjectHashMap (gnu.trove.TIntObjectHashMap)1 MouseEvent (java.awt.event.MouseEvent)1