mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
git: hide update action if no remotes even configured
The same behavior already exist in fetch action GitOrigin-RevId: 027a180df51f2490e2f23595635ac7c2fe095f95
This commit is contained in:
committed by
intellij-monorepo-bot
parent
69e4febbcb
commit
789cbf5102
@@ -2,13 +2,13 @@
|
||||
package git4idea.ui.branch
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger
|
||||
import com.intellij.openapi.diagnostic.logger
|
||||
import com.intellij.openapi.progress.ProgressIndicator
|
||||
import com.intellij.openapi.progress.ProgressManager
|
||||
import com.intellij.openapi.progress.Task
|
||||
import com.intellij.openapi.project.Project
|
||||
import com.intellij.openapi.vcs.VcsException
|
||||
import com.intellij.openapi.vcs.VcsNotifier
|
||||
import git4idea.GitUtil
|
||||
import git4idea.GitVcs
|
||||
import git4idea.branch.GitBrancher
|
||||
import git4idea.branch.GitNewBranchDialog
|
||||
@@ -159,3 +159,7 @@ internal fun isTrackingInfosExist(branchNames: List<String>, repositories: List<
|
||||
repositories
|
||||
.flatMap(GitRepository::getBranchTrackInfos)
|
||||
.any { trackingBranchInfo -> branchNames.any { branchName -> branchName == trackingBranchInfo.localBranch.name } }
|
||||
|
||||
internal fun hasRemotes(project: Project): Boolean {
|
||||
return GitUtil.getRepositories(project).any { repository -> !repository.remotes.isEmpty() }
|
||||
}
|
||||
|
||||
@@ -793,6 +793,11 @@ public class GitBranchPopupActions {
|
||||
@Override
|
||||
public void update(@NotNull AnActionEvent e) {
|
||||
Presentation presentation = e.getPresentation();
|
||||
Project project = e.getProject();
|
||||
if (project == null || !hasRemotes(project)) {
|
||||
presentation.setEnabledAndVisible(false);
|
||||
return;
|
||||
}
|
||||
String branchPresentation = getBranchPresentation(myBranchName);
|
||||
String description = String.format("Fetch remote tracking branch and fast-forward %s (like `git fetch %s:%s`)",
|
||||
branchPresentation, myBranchName, myBranchName);
|
||||
|
||||
@@ -21,10 +21,7 @@ import git4idea.fetch.GitFetchSupport
|
||||
import git4idea.isRemoteBranchProtected
|
||||
import git4idea.repo.GitRepository
|
||||
import git4idea.repo.GitRepositoryManager
|
||||
import git4idea.ui.branch.GitBranchPopupActions
|
||||
import git4idea.ui.branch.createOrCheckoutNewBranch
|
||||
import git4idea.ui.branch.isTrackingInfosExist
|
||||
import git4idea.ui.branch.updateBranches
|
||||
import git4idea.ui.branch.*
|
||||
import javax.swing.Icon
|
||||
|
||||
internal object BranchesDashboardActions {
|
||||
@@ -116,6 +113,15 @@ internal object BranchesDashboardActions {
|
||||
}
|
||||
|
||||
class UpdateSelectedBranchAction : BranchesActionBase(text = "Update Selected", icon = AllIcons.Actions.CheckOut) {
|
||||
override fun update(e: AnActionEvent) {
|
||||
val enabledAndVisible = e.project?.let(::hasRemotes) ?: false
|
||||
e.presentation.isEnabledAndVisible = enabledAndVisible
|
||||
|
||||
if (enabledAndVisible) {
|
||||
super.update(e)
|
||||
}
|
||||
}
|
||||
|
||||
override fun update(e: AnActionEvent, project: Project, branches: Collection<BranchInfo>) {
|
||||
val presentation = e.presentation
|
||||
if (GitFetchSupport.fetchSupport(project).isFetchRunning) {
|
||||
|
||||
Reference in New Issue
Block a user