diff --git a/plugins/git4idea/src/git4idea/GitProtectedBranches.kt b/plugins/git4idea/src/git4idea/GitProtectedBranches.kt index 8a42f746f63b..025291a7bdcb 100644 --- a/plugins/git4idea/src/git4idea/GitProtectedBranches.kt +++ b/plugins/git4idea/src/git4idea/GitProtectedBranches.kt @@ -22,6 +22,15 @@ fun findProtectedRemoteBranch(repository: GitRepository, branches: Collection, branchName: String): Boolean { + return repositories.any { findProtectedRemoteBranch(it, listOf(branchName)) != null } +} + fun findProtectedRemoteBranchContainingCommit(repository: GitRepository, hash: Hash): String? { val root = repository.root val branchesGetter = VcsProjectLog.getInstance(repository.project).dataManager?.containingBranchesGetter diff --git a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java index e63048e591e2..3998b09c8ec1 100644 --- a/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java +++ b/plugins/git4idea/src/git4idea/ui/branch/GitBranchPopupActions.java @@ -29,6 +29,7 @@ import com.intellij.openapi.util.text.StringUtil; import com.intellij.util.ui.EmptyIcon; import git4idea.GitBranch; import git4idea.GitLocalBranch; +import git4idea.GitProtectedBranchesKt; import git4idea.actions.GitAbstractRebaseAction; import git4idea.branch.*; import git4idea.config.GitVcsSettings; @@ -518,6 +519,11 @@ class GitBranchPopupActions { brancher.deleteRemoteBranch(myBranchName, myRepositories); reportUsage(myProject, "git.branch.delete.remote"); } + + @Override + public void update(AnActionEvent e) { + e.getPresentation().setEnabled(!GitProtectedBranchesKt.isRemoteBranchProtected(myRepositories, myBranchName)); + } } }