From df63f2a5aca780ede0f3501941f7816efbe047ac Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Fri, 8 May 2015 18:11:46 +0300 Subject: [PATCH] [git] IDEA-91996 Guess repository if there are no virtual files in the scope --- .../src/git4idea/actions/GitRepositoryAction.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plugins/git4idea/src/git4idea/actions/GitRepositoryAction.java b/plugins/git4idea/src/git4idea/actions/GitRepositoryAction.java index 50ba95a046fb..68d5aba3f6e0 100644 --- a/plugins/git4idea/src/git4idea/actions/GitRepositoryAction.java +++ b/plugins/git4idea/src/git4idea/actions/GitRepositoryAction.java @@ -15,6 +15,7 @@ */ package git4idea.actions; +import com.intellij.dvcs.repo.Repository; import com.intellij.openapi.actionSystem.ActionPlaces; import com.intellij.openapi.actionSystem.AnActionEvent; import com.intellij.openapi.actionSystem.CommonDataKeys; @@ -114,19 +115,18 @@ public abstract class GitRepositoryAction extends DumbAwareAction { if (files != null) { for (VirtualFile file : files) { GitRepositoryManager manager = GitUtil.getRepositoryManager(project); - if (manager == null) { - return false; - } - final GitRepository repositoryForFile = manager.getRepositoryForFile(file); - if (repositoryForFile != null && repositoryForFile.getState() == GitRepository.State.REBASING) { - return true; - } + if (isRebasing(manager.getRepositoryForFile(file))) return true; } } + if (isRebasing(GitBranchUtil.getCurrentRepository(project))) return true; } return false; } + private static boolean isRebasing(@Nullable GitRepository repository) { + return repository != null && repository.getState() == Repository.State.REBASING; + } + /** * Get git roots for the project. The method shows dialogs in the case when roots cannot be retrieved, so it should be called * from the event dispatch thread.