From 6fa42c5eb1fa2818121668d393a4d76c835917d8 Mon Sep 17 00:00:00 2001 From: OpherV Date: Thu, 5 Sep 2019 16:55:44 +0300 Subject: [PATCH 1/8] Icons on toolbar cause NPE #232 --- .../java/gitflow/actions/AbstractStartAction.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/gitflow/actions/AbstractStartAction.java b/src/main/java/gitflow/actions/AbstractStartAction.java index aa6efa1..2b84906 100644 --- a/src/main/java/gitflow/actions/AbstractStartAction.java +++ b/src/main/java/gitflow/actions/AbstractStartAction.java @@ -19,12 +19,13 @@ public abstract class AbstractStartAction extends GitflowAction { @Override public void update(@NotNull AnActionEvent e) { GitflowBranchUtil branchUtil = GitflowBranchUtilManager.getBranchUtil(myRepo); - - //Disable and hide when gitflow has not been setup - if (branchUtil.hasGitflow() == false) { - e.getPresentation().setEnabledAndVisible(false); - } else { - e.getPresentation().setEnabledAndVisible(true); + if (branchUtil != null) { + //Disable and hide when gitflow has not been setup + if (branchUtil.hasGitflow() == false) { + e.getPresentation().setEnabledAndVisible(false); + } else { + e.getPresentation().setEnabledAndVisible(true); + } } } } From 09bd4a155496cb0858eb4e9c6699d3fafed85c8a Mon Sep 17 00:00:00 2001 From: Opher Vishnia Date: Fri, 13 Dec 2019 14:36:29 +0200 Subject: [PATCH 2/8] fix #255 Memory leak of ProjectImpl and GitRepositoryImpl after project is closed --- src/main/java/gitflow/GitflowBranchUtilManager.java | 3 +++ src/main/java/gitflow/GitflowConfigUtil.java | 5 +++++ 2 files changed, 8 insertions(+) diff --git a/src/main/java/gitflow/GitflowBranchUtilManager.java b/src/main/java/gitflow/GitflowBranchUtilManager.java index 6fc2dba..2ed4949 100644 --- a/src/main/java/gitflow/GitflowBranchUtilManager.java +++ b/src/main/java/gitflow/GitflowBranchUtilManager.java @@ -6,6 +6,7 @@ import com.intellij.openapi.progress.ProgressManager; import com.intellij.openapi.progress.Task; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Disposer; import git4idea.GitUtil; import git4idea.repo.GitRepository; import gitflow.actions.GitflowActions; @@ -36,6 +37,8 @@ static public GitflowBranchUtil getBranchUtil(GitRepository repo){ static public void setupBranchUtil(Project project, GitRepository repo){ GitflowBranchUtil gitflowBranchUtil = new GitflowBranchUtil(project, repo); repoBranchUtilMap.put(repo, gitflowBranchUtil); + // clean up + Disposer.register(repo, () -> repoBranchUtilMap.remove(repo)); } /** diff --git a/src/main/java/gitflow/GitflowConfigUtil.java b/src/main/java/gitflow/GitflowConfigUtil.java index 96cd1bd..692c8b1 100644 --- a/src/main/java/gitflow/GitflowConfigUtil.java +++ b/src/main/java/gitflow/GitflowConfigUtil.java @@ -4,6 +4,7 @@ import java.util.concurrent.Future; import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.project.Project; +import com.intellij.openapi.util.Disposer; import com.intellij.openapi.vcs.VcsException; import com.intellij.openapi.vfs.VirtualFile; import git4idea.config.GitConfigUtil; @@ -54,6 +55,10 @@ public static GitflowConfigUtil getInstance(Project project_, GitRepository repo gitflowConfigUtilMap.put(project_, innerMap); innerMap.put(repo_, instance); + + //cleanup + Disposer.register(repo_, () -> innerMap.remove(repo_)); + Disposer.register(project_, () -> gitflowConfigUtilMap.remove(project_)); } return instance; From df35bd364aae52d531c784345eb119bc1c739a1e Mon Sep 17 00:00:00 2001 From: Opher Vishnia Date: Fri, 13 Dec 2019 14:54:52 +0200 Subject: [PATCH 3/8] Add safety which should help fix #249 Init repo failed --- src/main/java/gitflow/actions/InitRepoAction.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/main/java/gitflow/actions/InitRepoAction.java b/src/main/java/gitflow/actions/InitRepoAction.java index 3f3ac9f..7a731e3 100644 --- a/src/main/java/gitflow/actions/InitRepoAction.java +++ b/src/main/java/gitflow/actions/InitRepoAction.java @@ -34,12 +34,13 @@ public class InitRepoAction extends GitflowAction { @Override public void update(@NotNull AnActionEvent e) { GitflowBranchUtil branchUtil = GitflowBranchUtilManager.getBranchUtil(myRepo); - - // Only show when gitflow isn't setup - if (branchUtil.hasGitflow()) { - e.getPresentation().setEnabledAndVisible(false); - } else { - e.getPresentation().setEnabledAndVisible(true); + if (branchUtil != null) { + // Only show when gitflow isn't setup + if (branchUtil.hasGitflow()) { + e.getPresentation().setEnabledAndVisible(false); + } else { + e.getPresentation().setEnabledAndVisible(true); + } } } From 047b5ec65d16a799a68d25a07b23ccfb66fe7f18 Mon Sep 17 00:00:00 2001 From: Opher Vishnia Date: Fri, 13 Dec 2019 23:15:19 +0200 Subject: [PATCH 4/8] Check that the user has AVH version of git flow installed, show dialog otherwise #253 --- GITFLOW_VERISON.MD | 22 +++++++++ README.md | 12 +---- src/main/java/gitflow/GitflowComponent.java | 31 ++++++++----- .../java/gitflow/GitflowVersionTester.java | 31 +++++++++++++ .../ui/GitflowUnsupportedVersionWidget.java | 30 +++++++++++++ .../UnsupportedVersionWidgetPresentation.java | 45 +++++++++++++++++++ 6 files changed, 150 insertions(+), 21 deletions(-) create mode 100644 GITFLOW_VERISON.MD create mode 100644 src/main/java/gitflow/GitflowVersionTester.java create mode 100644 src/main/java/gitflow/ui/GitflowUnsupportedVersionWidget.java create mode 100644 src/main/java/gitflow/ui/UnsupportedVersionWidgetPresentation.java diff --git a/GITFLOW_VERISON.MD b/GITFLOW_VERISON.MD new file mode 100644 index 0000000..7abd37d --- /dev/null +++ b/GITFLOW_VERISON.MD @@ -0,0 +1,22 @@ +The plugin requires that you have gitflow installed, specifically the [AVH edition](https://github.com/petervanderdoes/gitflow). This is because the [Vanilla Git Flow](https://github.com/nvie/gitflow) hasn't been maintained in years + +**How to check Git Flow version** + +run `git flow version` + +If it says `0.4.1` then you have the wrong version. You will have to uninstall it and then refer to [AVH edition](https://github.com/petervanderdoes/gitflow) docs for installation. + + +**How to uninstall wrong version on OSX** + +If installed via `brew` then run `brew uninstall git-flow` + + +**Mac/Linux users:** + +If you're running into issues like getting +`Gitflow is not installed` +or +`git: 'flow' is not a git command. See 'git --help'.` + +Please be sure to check out [this thread](https://github.com/OpherV/gitflow4idea/issues/7) diff --git a/README.md b/README.md index d2de481..d9b97b3 100644 --- a/README.md +++ b/README.md @@ -35,17 +35,7 @@ Huge shoutout [to Kirill Likhodedov](https://github.com/klikh), who wrote much o The plugin is available via the IntelliJ plugin manager. Just search for "Git Flow Integration" to get the latest version! -(The plugin requires that you have gitflow installed. I *highly* recommend using the [AVH edition](https://github.com/petervanderdoes/gitflow), rather than [Vanilla Git Flow](https://github.com/nvie/gitflow) since the original isn't being maintained anymore) - -**Mac/Linux users:** - -If you're running into issues like getting -`Gitflow is not installed` -or -`git: 'flow' is not a git command. See 'git --help'.` - -Please be sure to check out [this thread](https://github.com/OpherV/gitflow4idea/issues/7) - +**The plugin requires that you have gitflow installed, specifically the [AVH edition](https://github.com/petervanderdoes/gitflow). This is because the [Vanilla Git Flow](https://github.com/nvie/gitflow) hasn't been maintained in years.** See this page [for details](https://github.com/OpherV/gitflow4idea/blob/develop/GITFLOW_VERSION.md) ## Caveats diff --git a/src/main/java/gitflow/GitflowComponent.java b/src/main/java/gitflow/GitflowComponent.java index 5b9b885..fa6b75a 100644 --- a/src/main/java/gitflow/GitflowComponent.java +++ b/src/main/java/gitflow/GitflowComponent.java @@ -1,17 +1,21 @@ package gitflow; +import com.intellij.openapi.application.ApplicationManager; import com.intellij.openapi.components.ProjectComponent; import com.intellij.openapi.project.Project; import com.intellij.openapi.vcs.ProjectLevelVcsManager; import com.intellij.openapi.vcs.VcsListener; import com.intellij.openapi.vcs.VcsRoot; import com.intellij.openapi.wm.StatusBar; +import com.intellij.openapi.wm.StatusBarWidget; import com.intellij.openapi.wm.WindowManager; import com.intellij.util.messages.MessageBus; import git4idea.GitVcs; +import gitflow.ui.GitflowUnsupportedVersionWidget; import gitflow.ui.GitflowWidget; import org.jetbrains.annotations.NotNull; + /** * @author Opher Vishnia / opherv.com / opherv@gmail.com */ @@ -48,25 +52,32 @@ public void projectClosed() { @Override public void directoryMappingChanged() { - VcsRoot[] vcsRoots=ProjectLevelVcsManager.getInstance(myProject).getAllVcsRoots(); + VcsRoot[] vcsRoots = ProjectLevelVcsManager.getInstance(myProject).getAllVcsRoots(); + StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject); //git repo present - if (vcsRoots.length>0 && vcsRoots[0].getVcs() instanceof GitVcs){ + if (vcsRoots.length > 0 && vcsRoots[0].getVcs() instanceof GitVcs) { + + + StatusBarWidget widgetToAdd; //make sure to not reinitialize the widget if it's already present - if (myGitflowWidget == null) { + if (GitflowVersionTester.isSupportedVersion() && myGitflowWidget == null) { myGitflowWidget = new GitflowWidget(myProject); - StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject); - if (statusBar != null) { - statusBar.addWidget(myGitflowWidget, "after " + git4idea.ui.branch.GitBranchWidget.class.getName(), myProject); - } + widgetToAdd = (StatusBarWidget) myGitflowWidget; + } else { + widgetToAdd = new GitflowUnsupportedVersionWidget(myProject); } - } - else{ - if (myGitflowWidget!=null){ + + if (statusBar != null) { + statusBar.addWidget(widgetToAdd, "after " + git4idea.ui.branch.GitBranchWidget.class.getName(), myProject); + } + } else { + if (myGitflowWidget != null) { myGitflowWidget.deactivate(); } myGitflowWidget = null; } } + } diff --git a/src/main/java/gitflow/GitflowVersionTester.java b/src/main/java/gitflow/GitflowVersionTester.java new file mode 100644 index 0000000..adbcb4f --- /dev/null +++ b/src/main/java/gitflow/GitflowVersionTester.java @@ -0,0 +1,31 @@ +package gitflow; + +import com.intellij.execution.configurations.GeneralCommandLine; +import com.intellij.execution.ExecutionException; +import com.intellij.execution.util.ExecUtil; +import com.intellij.execution.process.ProcessOutput; + +public class GitflowVersionTester { + static Boolean isSupportedVersion = null; + + static boolean isSupportedVersion(){ + if (isSupportedVersion == null) { + + ProcessOutput output = null; + GeneralCommandLine commandLine = new GeneralCommandLine(); + commandLine.setExePath("git"); + commandLine.addParameters("flow"); + commandLine.addParameters("version"); + try { + output = ExecUtil.execAndGetOutput(commandLine); + } catch (ExecutionException e) { + e.printStackTrace(); + } + String stdout = output.getStdout(); +// System.out.println("output: " + stdout); + // test that the installed git flow CLI version is AVH and not the unmaintained NVIE version + isSupportedVersion = stdout.contains("AVH"); + } + return isSupportedVersion; + } +} diff --git a/src/main/java/gitflow/ui/GitflowUnsupportedVersionWidget.java b/src/main/java/gitflow/ui/GitflowUnsupportedVersionWidget.java new file mode 100644 index 0000000..e554cf8 --- /dev/null +++ b/src/main/java/gitflow/ui/GitflowUnsupportedVersionWidget.java @@ -0,0 +1,30 @@ +package gitflow.ui; + +import com.intellij.openapi.project.Project; +import com.intellij.openapi.wm.StatusBarWidget; +import com.intellij.openapi.wm.StatusBarWidget.TextPresentation; +import com.intellij.openapi.wm.impl.status.EditorBasedWidget; +import com.intellij.util.Consumer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.awt.event.MouseEvent; + +public class GitflowUnsupportedVersionWidget extends EditorBasedWidget { + + public GitflowUnsupportedVersionWidget(@NotNull Project project) { + super(project); + } + + @NotNull + @Override + public String ID() { + return "GitflowUnsupportedVersionWidget"; + } + + @Nullable + @Override + public WidgetPresentation getPresentation(@NotNull PlatformType type) { + return new UnsupportedVersionWidgetPresentation(); + } +} \ No newline at end of file diff --git a/src/main/java/gitflow/ui/UnsupportedVersionWidgetPresentation.java b/src/main/java/gitflow/ui/UnsupportedVersionWidgetPresentation.java new file mode 100644 index 0000000..1a0d357 --- /dev/null +++ b/src/main/java/gitflow/ui/UnsupportedVersionWidgetPresentation.java @@ -0,0 +1,45 @@ +package gitflow.ui; + +import com.intellij.ide.BrowserUtil; +import com.intellij.openapi.ui.MessageDialogBuilder; +import com.intellij.openapi.ui.Messages; +import com.intellij.openapi.wm.StatusBarWidget; +import com.intellij.util.Consumer; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.annotations.Nullable; + +import java.awt.event.MouseEvent; + +public class UnsupportedVersionWidgetPresentation implements StatusBarWidget.TextPresentation { + + @NotNull + @Override + public String getText() { + return "Unsupported Git Flow Verison"; + } + + @Override + public float getAlignment() { + return 0; + } + + @Nullable + @Override + public String getTooltipText() { + return "Click for details"; + } + + @Nullable + @Override + public Consumer getClickConsumer() { + return mouseEvent -> { + MessageDialogBuilder.YesNo builder = MessageDialogBuilder.yesNo("Unsupported Git Flow version", "The Git Flow CLI version installed isn't supported by the Git Flow Integration plugin") + .yesText("More information (open browser)") + .noText("no"); + if (builder.show() == Messages.OK) { + BrowserUtil.browse("https://github.com/OpherV/gitflow4idea/blob/develop/GITFLOW_VERSION.md"); + } + }; + + } +} From 82c56e436b6a6d5ffa6cb510f67b572b806ce978 Mon Sep 17 00:00:00 2001 From: Opher Vishnia Date: Fri, 13 Dec 2019 23:17:01 +0200 Subject: [PATCH 5/8] 193 build compatibility #259 --- build.gradle | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/build.gradle b/build.gradle index a0c0ca3..98775ae 100644 --- a/build.gradle +++ b/build.gradle @@ -8,7 +8,7 @@ compileJava { } group 'gitflow4idea' -version '0.7.0' +version '0.7.1' sourceCompatibility = JavaVersion.VERSION_1_8 targetCompatibility = JavaVersion.VERSION_1_8 @@ -29,9 +29,9 @@ intellij { patchPluginXml { pluginId "Gitflow" pluginDescription 'Git Flow Integration' - version '0.7.0' + version '0.7.1' sinceBuild '182.0' - untilBuild '192.*' + untilBuild '193.*' changeNotes """

Changelog for 0.7.0

From 607e8c5cefbd433dabc6f6468488e44b3978b21d Mon Sep 17 00:00:00 2001 From: Opher Vishnia Date: Fri, 13 Dec 2019 23:38:14 +0200 Subject: [PATCH 6/8] Add icons to actions #232 --- src/main/resources/META-INF/plugin.xml | 69 ++++++++++++++++++++------ 1 file changed, 53 insertions(+), 16 deletions(-) diff --git a/src/main/resources/META-INF/plugin.xml b/src/main/resources/META-INF/plugin.xml index a2cac2d..f588b16 100644 --- a/src/main/resources/META-INF/plugin.xml +++ b/src/main/resources/META-INF/plugin.xml @@ -18,43 +18,80 @@ text="Gitflow Operations Popup..." /> + text="Initialize Gitflow Repository..." + icon="AllIcons.Actions.Lightning" + /> + + text="Start Feature..." + icon="AllIcons.Vcs.Branch" + /> + text="Finish Feature" + icon="AllIcons.Vcs.Merge" + /> + text="Publish Feature" + icon="AllIcons.Vcs.Push" + /> + text="Track Feature..." + icon="AllIcons.Vcs." + /> + text="Start Release..." + icon="AllIcons.Vcs.Branch" + /> + text="Finish Release" + icon="AllIcons.Vcs.Merge" + /> + text="Publish Release" + icon="AllIcons.Vcs.Push" + /> + text="Track Release..." + icon="AllIcons.Actions.CheckOut" + /> + text="Start Hotfix..." + icon="AllIcons.Vcs.Branch" + /> + text="Finish Hotfix" + icon="AllIcons.Vcs.Merge" + /> + + text="Publish Hotfix" + icon="AllIcons.Vcs.Push" + /> + text="Start Bugfix..." + icon="AllIcons.Vcs.Branch" + /> + + text="Finish Bugfix" + icon="AllIcons.Vcs.Merge" + /> + + text="Publish Bugfix" + icon="AllIcons.Vcs.Push" + /> + + text="Track Bugfix..." + icon="AllIcons.Actions.CheckOut" + /> From 171725af5905dce78f51a7f28abbbd967e85ba74 Mon Sep 17 00:00:00 2001 From: Opher Vishnia Date: Fri, 13 Dec 2019 23:42:17 +0200 Subject: [PATCH 7/8] Update changelog --- build.gradle | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/build.gradle b/build.gradle index 98775ae..0aedb25 100644 --- a/build.gradle +++ b/build.gradle @@ -34,6 +34,15 @@ patchPluginXml { untilBuild '193.*' changeNotes """ +

Changelog for 0.7.1

+
    +
  • Support for Idea build 193 #259 (@opherv)
  • +
  • Check that the user has AVH version of git flow installed, show dialog otherwise #253 (@opherv)
  • +
  • Add safety which should help fix #249 - Init repo failed #259 (@opherv)
  • +
  • Fix Memory leak of ProjectImpl and GitRepositoryImpl after projet is closed #255 (@opherv)
  • +
  • Add icons to actions #232 (@opherv)
  • +
+

Changelog for 0.7.0

  • Fix NPE when clicking Gitflow menu #245 (@opherv)
  • From 2bc835c4353a831d5c992b4f20a734d1bfab24d8 Mon Sep 17 00:00:00 2001 From: Opher Vishnia Date: Fri, 13 Dec 2019 23:42:41 +0200 Subject: [PATCH 8/8] Update intellij version in gradle --- build.gradle | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 0aedb25..6095d04 100644 --- a/build.gradle +++ b/build.gradle @@ -22,7 +22,7 @@ dependencies { } intellij { - version '2019.2' + version '2019.3' plugins 'git4idea', 'tasks' }