Skip to content

Commit

Permalink
Fix Breaking 'Search Everywhere' dialog window for projects without git
Browse files Browse the repository at this point in the history
  • Loading branch information
OpherV committed May 3, 2020
1 parent cf33168 commit e2f8e85
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 14 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ patchPluginXml {
<li>Support for Idea build 200 #276 (@fabmars, @tumb1er )</li>
<li>Fix Icon cannot be found in 'AllIcons.Vcs.' #286 (@fabmars)</li>
<li>Fix finish release error (Mac OS) #273 (@opherv)</li>
<li>Breaking 'Search Everywhere' dialog window for projects without git #265 (@opherv)</li>
</ul>
<H2>Changelog for 0.7.1</H2>
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gitflow/GitflowVersionTester.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public static GitflowVersionTester forProject(@NotNull Project project) {
@NotNull private final Gitflow gitflow;
@NotNull private final Project project;

private String version;
private String version = null;

private GitflowVersionTester(@NotNull Gitflow gitflow, @NotNull Project project) {
this.gitflow = gitflow;
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/gitflow/actions/ReInitRepoAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public void update(@NotNull AnActionEvent e) {
gitflow.GitflowBranchUtil branchUtil = gitflow.GitflowBranchUtilManager.getBranchUtil(myRepo);

// Only show when gitflow is setup
if (branchUtil.hasGitflow()) {
if (branchUtil !=null && branchUtil.hasGitflow()) {
e.getPresentation().setEnabledAndVisible(true);
} else {
e.getPresentation().setEnabledAndVisible(false);
Expand Down
35 changes: 23 additions & 12 deletions src/main/java/gitflow/ui/GitflowWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@
import com.intellij.ui.awt.RelativePoint;
import com.intellij.ui.popup.PopupFactoryImpl;
import com.intellij.util.Consumer;
import com.intellij.openapi.vcs.VcsRoot;
import com.intellij.openapi.vcs.ProjectLevelVcsManager;

import gitflow.GitflowBranchUtil;
import gitflow.GitflowBranchUtilManager;
Expand All @@ -49,6 +51,7 @@
import git4idea.repo.GitRepository;
import git4idea.repo.GitRepositoryChangeListener;
import git4idea.ui.branch.GitBranchWidget;
import git4idea.GitVcs;

/**
* Status bar widget which displays actions for git flow
Expand All @@ -64,18 +67,6 @@ public class GitflowWidget extends GitBranchWidget implements GitRepositoryChang
public GitflowWidget(@NotNull Project project) {
super(project);
project.getMessageBus().connect().subscribe(GitRepository.GIT_REPO_CHANGE, this);

// init the gitflow cli version check in a new thread and not on the EDT
final Runnable runnable = new Runnable()
{
@Override
public void run()
{
GitflowVersionTester.forProject(myProject).init();
}
};
new Thread(runnable).start();

}

@Override
Expand Down Expand Up @@ -111,6 +102,7 @@ public void fileClosed(FileEditorManager source, VirtualFile file) {

@Override
public void repositoryChanged(@NotNull GitRepository repository) {
initVersionCheck();
updateAsync();
}

Expand Down Expand Up @@ -280,4 +272,23 @@ public boolean getIsSupportedVersion(){
return GitflowVersionTester.forProject(myProject).isSupportedVersion();
}

private void initVersionCheck(){

// init the gitflow cli version check in a new thread and not on the EDT
String version = GitflowVersionTester.forProject(myProject).getVersion();
if (version == null) {
final Runnable runnable = new Runnable() {
@Override
public void run() {
VcsRoot[] vcsRoots = ProjectLevelVcsManager.getInstance(myProject).getAllVcsRoots();
if (vcsRoots.length > 0 && vcsRoots[0].getVcs() instanceof GitVcs) {
GitflowVersionTester.forProject(myProject).init();
}

}
};
new Thread(runnable).start();
}
}

}

0 comments on commit e2f8e85

Please sign in to comment.