Skip to content

Commit b41850b

Browse files
committed
Merge branch 'release/0.7.2'
2 parents 9058f74 + e2f8e85 commit b41850b

24 files changed

+333
-169
lines changed
File renamed without changes.

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,6 @@ Feedback and suggestions are also very welcome.
5050
## License
5151

5252
This plugin is under the [Apache 2.0 license](http://www.apache.org/licenses/LICENSE-2.0.html).
53-
Copyright 2013-2019, Opher Vishnia.
53+
Copyright 2013-2020, Opher Vishnia.
5454

5555

build.gradle

+14-6
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
plugins {
22
id 'java'
3-
id 'org.jetbrains.intellij' version '0.4.7'
3+
id 'org.jetbrains.intellij' version '0.4.18'
44
}
55

66
compileJava {
77
options.compilerArgs += ["-Xlint"]
88
}
99

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

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

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

2929
patchPluginXml {
3030
pluginId "Gitflow"
3131
pluginDescription 'Git Flow Integration'
32-
version '0.7.1'
33-
sinceBuild '182.0'
34-
untilBuild '193.*'
32+
version '0.7.2'
33+
sinceBuild '201.0'
34+
untilBuild '201.*'
3535
changeNotes """
3636
37+
<H2>Changelog for 0.7.2</H2>
38+
<ul>
39+
<li>Support for Idea build 200 #276 (@fabmars, @tumb1er )</li>
40+
<li>Fix Icon cannot be found in 'AllIcons.Vcs.' #286 (@fabmars)</li>
41+
<li>Fix finish release error (Mac OS) #273 (@opherv)</li>
42+
<li>Breaking 'Search Everywhere' dialog window for projects without git #265 (@opherv)</li>
43+
</ul>
44+
3745
<H2>Changelog for 0.7.1</H2>
3846
<ul>
3947
<li>Support for Idea build 193 #259 (@opherv)</li>

docs/project_setup.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -101,5 +101,5 @@ And that's it. You can now make changes to the source and run them.
101101

102102
#### Language level
103103

104-
This project is written to target Java 6, so make sure to set the project language level appropriately
105-
to avoid accidentally using newer features. You can do so in the module settings under "modules -> gitflow4idea -> sources -> Language level".
104+
This project is written to target Java 8, so make sure to set the project language level appropriately
105+
to avoid accidentally using newer features. You can do so in the module settings under "modules -> gitflow4idea -> sources -> Language level".

gradle/wrapper/gradle-wrapper.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
33
distributionPath=wrapper/dists
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists
6-
distributionUrl=https\://services.gradle.org/distributions/gradle-5.3.1-all.zip
6+
distributionUrl=https\://services.gradle.org/distributions/gradle-6.3-all.zip

src/main/java/gitflow/Gitflow.java

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package gitflow;
22

3+
import com.intellij.openapi.project.Project;
34
import git4idea.commands.Git;
45
import git4idea.commands.GitCommandResult;
56
import git4idea.commands.GitLineHandlerListener;
@@ -109,4 +110,5 @@ GitCommandResult trackBugfix(@NotNull GitRepository repository,
109110
@NotNull GitRemote remote,
110111
@Nullable GitLineHandlerListener... listeners);
111112

113+
GitCommandResult version(@NotNull Project project, GitLineHandlerListener... listeners);
112114
}
+12-43
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package gitflow;
22

3-
import com.intellij.openapi.application.ApplicationManager;
4-
import com.intellij.openapi.components.ProjectComponent;
3+
import com.intellij.openapi.Disposable;
54
import com.intellij.openapi.project.Project;
65
import com.intellij.openapi.vcs.ProjectLevelVcsManager;
76
import com.intellij.openapi.vcs.VcsListener;
@@ -11,73 +10,43 @@
1110
import com.intellij.openapi.wm.WindowManager;
1211
import com.intellij.util.messages.MessageBus;
1312
import git4idea.GitVcs;
14-
import gitflow.ui.GitflowUnsupportedVersionWidget;
1513
import gitflow.ui.GitflowWidget;
16-
import org.jetbrains.annotations.NotNull;
1714

1815

1916
/**
2017
* @author Opher Vishnia / opherv.com / [email protected]
18+
* One instance per project
2119
*/
22-
public class GitflowComponent implements ProjectComponent, VcsListener {
20+
public class GitflowComponent implements VcsListener, Disposable {
2321
Project myProject;
2422
GitflowWidget myGitflowWidget;
2523
MessageBus messageBus;
2624

2725
public GitflowComponent(Project project) {
2826
myProject = project;
29-
}
30-
31-
public void initComponent() {
3227
messageBus = myProject.getMessageBus();
3328
messageBus.connect().subscribe(ProjectLevelVcsManager.VCS_CONFIGURATION_CHANGED, this);
29+
// Seems the event triggering this component happens after the directory mapping change
30+
directoryMappingChanged();
3431
}
3532

36-
public void disposeComponent() {
33+
@Override
34+
public void dispose() {
3735
// TODO: insert component disposal logic here
3836
}
3937

40-
@NotNull
41-
public String getComponentName() {
42-
return "GitflowComponent";
43-
}
44-
45-
public void projectOpened() {
46-
47-
}
48-
49-
public void projectClosed() {
50-
51-
}
52-
5338
@Override
5439
public void directoryMappingChanged() {
5540
VcsRoot[] vcsRoots = ProjectLevelVcsManager.getInstance(myProject).getAllVcsRoots();
56-
StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
57-
58-
//git repo present
5941
if (vcsRoots.length > 0 && vcsRoots[0].getVcs() instanceof GitVcs) {
6042

61-
62-
StatusBarWidget widgetToAdd;
63-
64-
//make sure to not reinitialize the widget if it's already present
65-
if (GitflowVersionTester.isSupportedVersion() && myGitflowWidget == null) {
66-
myGitflowWidget = new GitflowWidget(myProject);
67-
widgetToAdd = (StatusBarWidget) myGitflowWidget;
43+
StatusBar statusBar = WindowManager.getInstance().getStatusBar(myProject);
44+
GitflowWidget widget = (GitflowWidget) statusBar.getWidget(GitflowWidget.class.getName());
45+
if (widget != null) {
46+
widget.updateAsync();
6847
} else {
69-
widgetToAdd = new GitflowUnsupportedVersionWidget(myProject);
48+
throw new NullPointerException("widget");
7049
}
71-
72-
if (statusBar != null) {
73-
statusBar.addWidget(widgetToAdd, "after " + git4idea.ui.branch.GitBranchWidget.class.getName(), myProject);
74-
}
75-
} else {
76-
if (myGitflowWidget != null) {
77-
myGitflowWidget.deactivate();
78-
}
79-
myGitflowWidget = null;
8050
}
8151
}
82-
8352
}

src/main/java/gitflow/GitflowImpl.java

+22-4
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,8 @@ public GitCommandResult finishRelease(@NotNull GitRepository repository,
244244
addOptionsCommand(h, repository.getProject(),"RELEASE_keepBranch");
245245
// addOptionsCommand(h, repository.getProject(),"RELEASE_squash");
246246

247+
h.addParameters(releaseName);
248+
247249
HashMap<String,String> dontTag = GitflowOptionsFactory.getOptionById("RELEASE_dontTag");
248250
if (GitflowConfigurable.isOptionActive(repository.getProject(), dontTag.get("id"))){
249251
h.addParameters(dontTag.get("flag"));
@@ -253,8 +255,6 @@ public GitCommandResult finishRelease(@NotNull GitRepository repository,
253255
h.addParameters(tagMessage);
254256
}
255257

256-
h.addParameters(releaseName);
257-
258258
for (GitLineHandlerListener listener : listeners) {
259259
h.addLineListener(listener);
260260
}
@@ -339,6 +339,8 @@ public GitCommandResult finishHotfix(@NotNull GitRepository repository,
339339
addOptionsCommand(h, repository.getProject(),"HOTFIX_fetchFromOrigin");
340340
addOptionsCommand(h, repository.getProject(),"HOTFIX_pushOnFinish");
341341

342+
h.addParameters(hotfixName);
343+
342344
HashMap<String,String> dontTag = GitflowOptionsFactory.getOptionById("HOTFIX_dontTag");
343345
if (GitflowConfigurable.isOptionActive(repository.getProject(), dontTag.get("id"))){
344346
h.addParameters(dontTag.get("flag"));
@@ -348,8 +350,6 @@ public GitCommandResult finishHotfix(@NotNull GitRepository repository,
348350
h.addParameters(tagMessage);
349351
}
350352

351-
h.addParameters(hotfixName);
352-
353353
for (GitLineHandlerListener listener : listeners) {
354354
h.addLineListener(listener);
355355
}
@@ -491,4 +491,22 @@ public GitCommandResult trackBugfix(@NotNull GitRepository repository,
491491
return runCommand(h);
492492
}
493493

494+
@Override
495+
public GitCommandResult version(@NotNull Project project, GitLineHandlerListener... listeners) {
496+
//getProjectFile is null for default project.
497+
if (project.isDefault()) {
498+
throw new IllegalArgumentException("Cannot determine git flow version for default project");
499+
} else {
500+
assert project.getProjectFile() != null : "No project file for " + project;
501+
}
502+
503+
final GitLineHandler h = new GitLineHandler(project, project.getProjectFile().getParent(), GitflowCommand());
504+
505+
h.addParameters("version");
506+
507+
for (GitLineHandlerListener listener : listeners) {
508+
h.addLineListener(listener);
509+
}
510+
return runCommand(h);
511+
}
494512
}
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,75 @@
11
package gitflow;
22

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;
3+
import com.intellij.openapi.components.ServiceManager;
4+
import com.intellij.openapi.diagnostic.Logger;
5+
import com.intellij.openapi.project.Project;
6+
import com.intellij.openapi.util.Disposer;
7+
import org.jetbrains.annotations.NotNull;
8+
9+
import javax.annotation.Nullable;
10+
import java.util.Map;
11+
import java.util.concurrent.ConcurrentHashMap;
712

813
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();
14+
15+
private static final Logger logger = Logger.getInstance(GitflowVersionTester.class);
16+
17+
private static final Map<Project, GitflowVersionTester> testers = new ConcurrentHashMap<>();
18+
19+
public static GitflowVersionTester forProject(@NotNull Project project) {
20+
return testers.computeIfAbsent(
21+
project,
22+
p -> {
23+
Disposer.register(p, () -> testers.remove(p));
24+
return new GitflowVersionTester(ServiceManager.getService(Gitflow.class), p);
2325
}
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");
26+
);
27+
}
28+
29+
@NotNull private final Gitflow gitflow;
30+
@NotNull private final Project project;
31+
32+
private String version = null;
33+
34+
private GitflowVersionTester(@NotNull Gitflow gitflow, @NotNull Project project) {
35+
this.gitflow = gitflow;
36+
this.project = project;
37+
}
38+
39+
/**
40+
* <p>Returns the installed {@code git-flow} version. The version
41+
* is loaded on the first call to this method and is determined
42+
* by looking at the output of a {@code git flow version} command.</p>
43+
* <p>If the command fails, {@code null} is returned.</p>
44+
*
45+
* @return the {@code git flow} version, or {@code null}
46+
*/
47+
@Nullable
48+
public String getVersion() {
49+
return version;
50+
}
51+
52+
/**
53+
* Returns true if the {@code git flow} version can be determined
54+
* and is any AVH version ({@code #contains("AVH")}) and
55+
* not the unmaintained NVIE version.
56+
*
57+
* @return true if we think the git flow version is an AVH version.
58+
*/
59+
public boolean isSupportedVersion() {
60+
return version != null && version.contains("AVH");
61+
}
62+
63+
public void init(){
64+
String returnedVersion = null;
65+
try {
66+
returnedVersion = gitflow.version(project).getOutputOrThrow();
67+
logger.info("git flow version: " + version);
68+
} catch (Exception e) {
69+
logger.error("Could not determine git flow version", e);
70+
}
71+
if (returnedVersion != null){
72+
version = returnedVersion;
2873
}
29-
return isSupportedVersion;
3074
}
3175
}

src/main/java/gitflow/actions/FinishBugfixAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void onSuccess() {
8888

8989
//merge conflicts if necessary
9090
if (errorLineHandler.hasMergeError){
91-
if (handleMerge()){
91+
if (handleMerge(project)){
9292
that.runAction(project, bugfixName);
9393
FinishBugfixAction completeFinishBugfixAction = new FinishBugfixAction(myRepo, bugfixName);
9494
}

src/main/java/gitflow/actions/FinishFeatureAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ public void onSuccess() {
8888

8989
//merge conflicts if necessary
9090
if (errorLineHandler.hasMergeError){
91-
if (handleMerge()){
91+
if (handleMerge(project)) {
9292
that.runAction(project, featureName);
9393
FinishFeatureAction completeFinishFeatureAction = new FinishFeatureAction(myRepo, featureName);
9494
}

src/main/java/gitflow/actions/FinishReleaseAction.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void onSuccess() {
102102

103103
//merge conflicts if necessary
104104
if (errorLineHandler.hasMergeError){
105-
if (handleMerge()) {
105+
if (handleMerge(myProject)) {
106106
FinishReleaseAction completeFinisReleaseAction = new FinishReleaseAction(releaseName, tagMessage);
107107
completeFinisReleaseAction.actionPerformed(event);
108108
}

0 commit comments

Comments
 (0)