mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[git] IDEA-91996 Guess repository if there are no virtual files in the scope
This commit is contained in:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user