Skip to content

Commit

Permalink
Merge branch 'release/0.7.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
OpherV committed Dec 13, 2019
2 parents 1a3b137 + 2bc835c commit 9058f74
Show file tree
Hide file tree
Showing 12 changed files with 238 additions and 53 deletions.
22 changes: 22 additions & 0 deletions GITFLOW_VERISON.MD
Original file line number Diff line number Diff line change
@@ -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)
12 changes: 1 addition & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 13 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -22,18 +22,27 @@ dependencies {
}

intellij {
version '2019.2'
version '2019.3'
plugins 'git4idea', 'tasks'
}

patchPluginXml {
pluginId "Gitflow"
pluginDescription 'Git Flow Integration'
version '0.7.0'
version '0.7.1'
sinceBuild '182.0'
untilBuild '192.*'
untilBuild '193.*'
changeNotes """
<H2>Changelog for 0.7.1</H2>
<ul>
<li>Support for Idea build 193 #259 (@opherv)</li>
<li>Check that the user has AVH version of git flow installed, show dialog otherwise #253 (@opherv)</li>
<li>Add safety which should help fix #249 - Init repo failed #259 (@opherv)</li>
<li>Fix Memory leak of ProjectImpl and GitRepositoryImpl after projet is closed #255 (@opherv)</li>
<li>Add icons to actions #232 (@opherv)</li>
</ul>
<H2>Changelog for 0.7.0</H2>
<ul>
<li>Fix NPE when clicking Gitflow menu #245 (@opherv)</li>
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/gitflow/GitflowBranchUtilManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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));
}

/**
Expand Down
31 changes: 21 additions & 10 deletions src/main/java/gitflow/GitflowComponent.java
Original file line number Diff line number Diff line change
@@ -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 / [email protected]
*/
Expand Down Expand Up @@ -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;
}
}

}
5 changes: 5 additions & 0 deletions src/main/java/gitflow/GitflowConfigUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
31 changes: 31 additions & 0 deletions src/main/java/gitflow/GitflowVersionTester.java
Original file line number Diff line number Diff line change
@@ -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;
}
}
13 changes: 7 additions & 6 deletions src/main/java/gitflow/actions/AbstractStartAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
}
13 changes: 7 additions & 6 deletions src/main/java/gitflow/actions/InitRepoAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

Expand Down
30 changes: 30 additions & 0 deletions src/main/java/gitflow/ui/GitflowUnsupportedVersionWidget.java
Original file line number Diff line number Diff line change
@@ -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();
}
}
45 changes: 45 additions & 0 deletions src/main/java/gitflow/ui/UnsupportedVersionWidgetPresentation.java
Original file line number Diff line number Diff line change
@@ -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<MouseEvent> 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");
}
};

}
}
Loading

0 comments on commit 9058f74

Please sign in to comment.