Skip to content

Commit 9058f74

Browse files
committed
Merge branch 'release/0.7.1'
2 parents 1a3b137 + 2bc835c commit 9058f74

12 files changed

+238
-53
lines changed

GITFLOW_VERISON.MD

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
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
2+
3+
**How to check Git Flow version**
4+
5+
run `git flow version`
6+
7+
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.
8+
9+
10+
**How to uninstall wrong version on OSX**
11+
12+
If installed via `brew` then run `brew uninstall git-flow`
13+
14+
15+
**Mac/Linux users:**
16+
17+
If you're running into issues like getting
18+
`Gitflow is not installed`
19+
or
20+
`git: 'flow' is not a git command. See 'git --help'.`
21+
22+
Please be sure to check out [this thread](https://github.com/OpherV/gitflow4idea/issues/7)

README.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,7 @@ Huge shoutout [to Kirill Likhodedov](https://github.com/klikh), who wrote much o
3535

3636
The plugin is available via the IntelliJ plugin manager. Just search for "Git Flow Integration" to get the latest version!
3737

38-
(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)
39-
40-
**Mac/Linux users:**
41-
42-
If you're running into issues like getting
43-
`Gitflow is not installed`
44-
or
45-
`git: 'flow' is not a git command. See 'git --help'.`
46-
47-
Please be sure to check out [this thread](https://github.com/OpherV/gitflow4idea/issues/7)
48-
38+
**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)
4939

5040
## Caveats
5141

build.gradle

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ compileJava {
88
}
99

1010
group 'gitflow4idea'
11-
version '0.7.0'
11+
version '0.7.1'
1212

1313
sourceCompatibility = JavaVersion.VERSION_1_8
1414
targetCompatibility = JavaVersion.VERSION_1_8
@@ -22,18 +22,27 @@ dependencies {
2222
}
2323

2424
intellij {
25-
version '2019.2'
25+
version '2019.3'
2626
plugins 'git4idea', 'tasks'
2727
}
2828

2929
patchPluginXml {
3030
pluginId "Gitflow"
3131
pluginDescription 'Git Flow Integration'
32-
version '0.7.0'
32+
version '0.7.1'
3333
sinceBuild '182.0'
34-
untilBuild '192.*'
34+
untilBuild '193.*'
3535
changeNotes """
3636
37+
<H2>Changelog for 0.7.1</H2>
38+
<ul>
39+
<li>Support for Idea build 193 #259 (@opherv)</li>
40+
<li>Check that the user has AVH version of git flow installed, show dialog otherwise #253 (@opherv)</li>
41+
<li>Add safety which should help fix #249 - Init repo failed #259 (@opherv)</li>
42+
<li>Fix Memory leak of ProjectImpl and GitRepositoryImpl after projet is closed #255 (@opherv)</li>
43+
<li>Add icons to actions #232 (@opherv)</li>
44+
</ul>
45+
3746
<H2>Changelog for 0.7.0</H2>
3847
<ul>
3948
<li>Fix NPE when clicking Gitflow menu #245 (@opherv)</li>

src/main/java/gitflow/GitflowBranchUtilManager.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import com.intellij.openapi.progress.ProgressManager;
77
import com.intellij.openapi.progress.Task;
88
import com.intellij.openapi.project.Project;
9+
import com.intellij.openapi.util.Disposer;
910
import git4idea.GitUtil;
1011
import git4idea.repo.GitRepository;
1112
import gitflow.actions.GitflowActions;
@@ -36,6 +37,8 @@ static public GitflowBranchUtil getBranchUtil(GitRepository repo){
3637
static public void setupBranchUtil(Project project, GitRepository repo){
3738
GitflowBranchUtil gitflowBranchUtil = new GitflowBranchUtil(project, repo);
3839
repoBranchUtilMap.put(repo, gitflowBranchUtil);
40+
// clean up
41+
Disposer.register(repo, () -> repoBranchUtilMap.remove(repo));
3942
}
4043

4144
/**

src/main/java/gitflow/GitflowComponent.java

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
package gitflow;
22

3+
import com.intellij.openapi.application.ApplicationManager;
34
import com.intellij.openapi.components.ProjectComponent;
45
import com.intellij.openapi.project.Project;
56
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
67
import com.intellij.openapi.vcs.VcsListener;
78
import com.intellij.openapi.vcs.VcsRoot;
89
import com.intellij.openapi.wm.StatusBar;
10+
import com.intellij.openapi.wm.StatusBarWidget;
911
import com.intellij.openapi.wm.WindowManager;
1012
import com.intellij.util.messages.MessageBus;
1113
import git4idea.GitVcs;
14+
import gitflow.ui.GitflowUnsupportedVersionWidget;
1215
import gitflow.ui.GitflowWidget;
1316
import org.jetbrains.annotations.NotNull;
1417

18+
1519
/**
1620
* @author Opher Vishnia / opherv.com / opherv@gmail.com
1721
*/
@@ -48,25 +52,32 @@ public void projectClosed() {
4852

4953
@Override
5054
public void directoryMappingChanged() {
51-
VcsRoot[] vcsRoots=ProjectLevelVcsManager.getInstance(myProject).getAllVcsRoots();
55+
VcsRoot[] vcsRoots = ProjectLevelVcsManager.getInstance(myProject).getAllVcsRoots();
56+
StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
5257

5358
//git repo present
54-
if (vcsRoots.length>0 && vcsRoots[0].getVcs() instanceof GitVcs){
59+
if (vcsRoots.length > 0 && vcsRoots[0].getVcs() instanceof GitVcs) {
60+
61+
62+
StatusBarWidget widgetToAdd;
5563

5664
//make sure to not reinitialize the widget if it's already present
57-
if (myGitflowWidget == null) {
65+
if (GitflowVersionTester.isSupportedVersion() && myGitflowWidget == null) {
5866
myGitflowWidget = new GitflowWidget(myProject);
59-
StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
60-
if (statusBar != null) {
61-
statusBar.addWidget(myGitflowWidget, "after " + git4idea.ui.branch.GitBranchWidget.class.getName(), myProject);
62-
}
67+
widgetToAdd = (StatusBarWidget) myGitflowWidget;
68+
} else {
69+
widgetToAdd = new GitflowUnsupportedVersionWidget(myProject);
6370
}
64-
}
65-
else{
66-
if (myGitflowWidget!=null){
71+
72+
if (statusBar != null) {
73+
statusBar.addWidget(widgetToAdd, "after " + git4idea.ui.branch.GitBranchWidget.class.getName(), myProject);
74+
}
75+
} else {
76+
if (myGitflowWidget != null) {
6777
myGitflowWidget.deactivate();
6878
}
6979
myGitflowWidget = null;
7080
}
7181
}
82+
7283
}

src/main/java/gitflow/GitflowConfigUtil.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import java.util.concurrent.Future;
55
import com.intellij.openapi.application.ApplicationManager;
66
import com.intellij.openapi.project.Project;
7+
import com.intellij.openapi.util.Disposer;
78
import com.intellij.openapi.vcs.VcsException;
89
import com.intellij.openapi.vfs.VirtualFile;
910
import git4idea.config.GitConfigUtil;
@@ -54,6 +55,10 @@ public static GitflowConfigUtil getInstance(Project project_, GitRepository repo
5455

5556
gitflowConfigUtilMap.put(project_, innerMap);
5657
innerMap.put(repo_, instance);
58+
59+
//cleanup
60+
Disposer.register(repo_, () -> innerMap.remove(repo_));
61+
Disposer.register(project_, () -> gitflowConfigUtilMap.remove(project_));
5762
}
5863

5964
return instance;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
package gitflow;
2+
3+
import com.intellij.execution.configurations.GeneralCommandLine;
4+
import com.intellij.execution.ExecutionException;
5+
import com.intellij.execution.util.ExecUtil;
6+
import com.intellij.execution.process.ProcessOutput;
7+
8+
public class GitflowVersionTester {
9+
static Boolean isSupportedVersion = null;
10+
11+
static boolean isSupportedVersion(){
12+
if (isSupportedVersion == null) {
13+
14+
ProcessOutput output = null;
15+
GeneralCommandLine commandLine = new GeneralCommandLine();
16+
commandLine.setExePath("git");
17+
commandLine.addParameters("flow");
18+
commandLine.addParameters("version");
19+
try {
20+
output = ExecUtil.execAndGetOutput(commandLine);
21+
} catch (ExecutionException e) {
22+
e.printStackTrace();
23+
}
24+
String stdout = output.getStdout();
25+
// System.out.println("output: " + stdout);
26+
// test that the installed git flow CLI version is AVH and not the unmaintained NVIE version
27+
isSupportedVersion = stdout.contains("AVH");
28+
}
29+
return isSupportedVersion;
30+
}
31+
}

src/main/java/gitflow/actions/AbstractStartAction.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,13 @@ public abstract class AbstractStartAction extends GitflowAction {
1919
@Override
2020
public void update(@NotNull AnActionEvent e) {
2121
GitflowBranchUtil branchUtil = GitflowBranchUtilManager.getBranchUtil(myRepo);
22-
23-
//Disable and hide when gitflow has not been setup
24-
if (branchUtil.hasGitflow() == false) {
25-
e.getPresentation().setEnabledAndVisible(false);
26-
} else {
27-
e.getPresentation().setEnabledAndVisible(true);
22+
if (branchUtil != null) {
23+
//Disable and hide when gitflow has not been setup
24+
if (branchUtil.hasGitflow() == false) {
25+
e.getPresentation().setEnabledAndVisible(false);
26+
} else {
27+
e.getPresentation().setEnabledAndVisible(true);
28+
}
2829
}
2930
}
3031
}

src/main/java/gitflow/actions/InitRepoAction.java

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,12 +34,13 @@ public class InitRepoAction extends GitflowAction {
3434
@Override
3535
public void update(@NotNull AnActionEvent e) {
3636
GitflowBranchUtil branchUtil = GitflowBranchUtilManager.getBranchUtil(myRepo);
37-
38-
// Only show when gitflow isn't setup
39-
if (branchUtil.hasGitflow()) {
40-
e.getPresentation().setEnabledAndVisible(false);
41-
} else {
42-
e.getPresentation().setEnabledAndVisible(true);
37+
if (branchUtil != null) {
38+
// Only show when gitflow isn't setup
39+
if (branchUtil.hasGitflow()) {
40+
e.getPresentation().setEnabledAndVisible(false);
41+
} else {
42+
e.getPresentation().setEnabledAndVisible(true);
43+
}
4344
}
4445
}
4546

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
package gitflow.ui;
2+
3+
import com.intellij.openapi.project.Project;
4+
import com.intellij.openapi.wm.StatusBarWidget;
5+
import com.intellij.openapi.wm.StatusBarWidget.TextPresentation;
6+
import com.intellij.openapi.wm.impl.status.EditorBasedWidget;
7+
import com.intellij.util.Consumer;
8+
import org.jetbrains.annotations.NotNull;
9+
import org.jetbrains.annotations.Nullable;
10+
11+
import java.awt.event.MouseEvent;
12+
13+
public class GitflowUnsupportedVersionWidget extends EditorBasedWidget {
14+
15+
public GitflowUnsupportedVersionWidget(@NotNull Project project) {
16+
super(project);
17+
}
18+
19+
@NotNull
20+
@Override
21+
public String ID() {
22+
return "GitflowUnsupportedVersionWidget";
23+
}
24+
25+
@Nullable
26+
@Override
27+
public WidgetPresentation getPresentation(@NotNull PlatformType type) {
28+
return new UnsupportedVersionWidgetPresentation();
29+
}
30+
}

0 commit comments

Comments
 (0)