From bc329f9aca7ec49fdf8b59d074d42fa12b4464e3 Mon Sep 17 00:00:00 2001 From: Julia Beliaeva Date: Fri, 1 Sep 2023 00:28:03 +0200 Subject: [PATCH] [vcs-log] disable "Show Git Log for Command" action for projects with non-git repositories GitOrigin-RevId: aa3646b5ecd00fa5ee29430a99ce5955c145f5b2 --- .../log/command/ShowGitLogCommandAction.kt | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/plugins/git4idea/src/git4idea/log/command/ShowGitLogCommandAction.kt b/plugins/git4idea/src/git4idea/log/command/ShowGitLogCommandAction.kt index 4c0cd86d68a1..8b3177990304 100644 --- a/plugins/git4idea/src/git4idea/log/command/ShowGitLogCommandAction.kt +++ b/plugins/git4idea/src/git4idea/log/command/ShowGitLogCommandAction.kt @@ -1,19 +1,33 @@ // Copyright 2000-2023 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license. package git4idea.log.command +import com.intellij.openapi.actionSystem.ActionUpdateThread import com.intellij.openapi.actionSystem.AnActionEvent import com.intellij.openapi.components.service import com.intellij.openapi.project.DumbAwareAction +import com.intellij.openapi.vcs.ProjectLevelVcsManager import com.intellij.openapi.wm.IdeFocusManager import com.intellij.vcs.log.impl.VcsLogContentUtil import com.intellij.vcs.log.impl.VcsLogProjectTabsProperties import com.intellij.vcs.log.impl.VcsLogTabsManager import com.intellij.vcs.log.impl.VcsProjectLog import com.intellij.vcs.log.visible.filters.VcsLogFilterObject +import git4idea.GitVcs import java.util.* @Suppress("HardCodedStringLiteral") // internal action class ShowGitLogCommandAction : DumbAwareAction("Show Git Log for Command") { + + override fun update(e: AnActionEvent) { + val project = e.project + if (project == null) { + e.presentation.isEnabledAndVisible = false + return + } + + e.presentation.isEnabledAndVisible = ProjectLevelVcsManager.getInstance(project).singleVCS?.keyInstanceMethod == GitVcs.getKey() + } + override fun actionPerformed(e: AnActionEvent) { val project = e.project!! VcsProjectLog.runWhenLogIsReady(project) { vcsLogManager -> @@ -26,4 +40,6 @@ class ShowGitLogCommandAction : DumbAwareAction("Show Git Log for Command") { IdeFocusManager.getInstance(project).requestFocus(ui.filterUi.textFilterComponent.focusedComponent, true) } } + + override fun getActionUpdateThread(): ActionUpdateThread = ActionUpdateThread.BGT } \ No newline at end of file