-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
238 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] | ||
*/ | ||
|
@@ -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; | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/main/java/gitflow/ui/GitflowUnsupportedVersionWidget.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
45
src/main/java/gitflow/ui/UnsupportedVersionWidgetPresentation.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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"); | ||
} | ||
}; | ||
|
||
} | ||
} |
Oops, something went wrong.