From d8dd8dd8c117d5aee08df9fad2585d988ce39e23 Mon Sep 17 00:00:00 2001
From: Alex Schwabe <->
Date: Fri, 4 Sep 2015 12:11:03 +0200
Subject: [PATCH 01/18] Changed gitignore to ignore all *.iml files instead of
one with a specific project name
---
.gitignore | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
index 0fdb83c..b954802 100644
--- a/.gitignore
+++ b/.gitignore
@@ -4,4 +4,4 @@
*.zip
*.jar
out
-gitflow.iml
\ No newline at end of file
+*.iml
\ No newline at end of file
From b9805839fd6ca9a98fa92962b14bf3a2653a5934 Mon Sep 17 00:00:00 2001
From: Alex Schwabe <->
Date: Fri, 4 Sep 2015 12:20:46 +0200
Subject: [PATCH 02/18] Added a small guide how to setup the project for
development
---
docs/project_setup.md | 56 +++++++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 docs/project_setup.md
diff --git a/docs/project_setup.md b/docs/project_setup.md
new file mode 100644
index 0000000..4c370a6
--- /dev/null
+++ b/docs/project_setup.md
@@ -0,0 +1,56 @@
+# Project setup help
+
+This is a quick overview how to setup the project for development.
+
+## 1. Make sure the plugin development plugin is enabled
+
+Start IDEA, go to Settings->Plugins and make sure that `Plugin DevKit` is installed and enabled.
+If it's not, install it now.
+
+## 2. Clone the project
+
+## 3. Import the project into IDEA
+
+Select "Import Project" and navigate to the cloned repository when prompted.
+ * Chose "From existing sources" when prompted for a model
+ * At the SDK step (if you dont have a plugin SDK yet): Click `+` to add an SDK and select "IntelliJ Platform Plugin SDK"
+ - Navigate to your IDEA installation and select the installation directory.
+ - Afterwards select a JDK when prompted
+ * At the SDK step select your Plugin SDK (if you followed the previous step select the newly created SDK)
+ * The remaining options can be left at default
+
+## 4. Change the project type
+
+Open the projects iml file (it should be named `gitflow4idea.iml` by default) and replace its contents with this:
+
+```
+
+
+
+
+
+
+
+
+
+
+
+```
+
+Then close and reopen the project to apply the changes.
+
+## 5. Add git4idea dependency
+
+Open the module settings and navigate to modules -> gitflow4idea (or your project name here) -> dependencies.
+Click add -> "JARs or directories" and add `git4idea.jar`.
+This can be found in your IDEA installation directory under `plugins/git4idea/lib`.
+Change the scope of the added JAR to **provided**.
+
+## 6. Create a run configuration
+
+Go to Run/Debug configurations and create a new configuration of the type `Plugin`. Under "Use classpath of module" select the project (`gitflow4idea` by default).
+Run it. A new IDEA instance should start with the plugin running.
+
+And that's it. You can now make changes to the source and run them.
+
+
From 2a70f2cd64dbe5f6049529bc1c03abc9e4160104 Mon Sep 17 00:00:00 2001
From: Alex Schwabe <->
Date: Fri, 4 Sep 2015 12:25:51 +0200
Subject: [PATCH 03/18] Fixed some bad formatting in the setup guide
---
docs/project_setup.md | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/docs/project_setup.md b/docs/project_setup.md
index 4c370a6..16ff418 100644
--- a/docs/project_setup.md
+++ b/docs/project_setup.md
@@ -12,12 +12,13 @@ If it's not, install it now.
## 3. Import the project into IDEA
Select "Import Project" and navigate to the cloned repository when prompted.
- * Chose "From existing sources" when prompted for a model
- * At the SDK step (if you dont have a plugin SDK yet): Click `+` to add an SDK and select "IntelliJ Platform Plugin SDK"
- - Navigate to your IDEA installation and select the installation directory.
- - Afterwards select a JDK when prompted
- * At the SDK step select your Plugin SDK (if you followed the previous step select the newly created SDK)
- * The remaining options can be left at default
+
+* Chose "From existing sources" when prompted for a model
+* At the SDK step (if you dont have a plugin SDK yet): Click `+` to add an SDK and select "IntelliJ Platform Plugin SDK"
+ - Navigate to your IDEA installation and select the installation directory.
+ - Afterwards select a JDK when prompted
+* At the SDK step select your Plugin SDK (if you followed the previous step select the newly created SDK)
+* The remaining options can be left at default
## 4. Change the project type
From 405473c9d623132f2e4256caa427ca09b8a23102 Mon Sep 17 00:00:00 2001
From: Alex Schwabe <->
Date: Fri, 4 Sep 2015 12:36:02 +0200
Subject: [PATCH 04/18] Reformatted project setup guide
* more consistent formatting
* syntax highlighting for github
---
docs/project_setup.md | 43 ++++++++++++++++++++++++++++---------------
1 file changed, 28 insertions(+), 15 deletions(-)
diff --git a/docs/project_setup.md b/docs/project_setup.md
index 16ff418..e75085e 100644
--- a/docs/project_setup.md
+++ b/docs/project_setup.md
@@ -4,27 +4,40 @@ This is a quick overview how to setup the project for development.
## 1. Make sure the plugin development plugin is enabled
-Start IDEA, go to Settings->Plugins and make sure that `Plugin DevKit` is installed and enabled.
+Start IDEA, go to *Settings -> Plugins* and make sure that `Plugin DevKit` is installed and enabled.
If it's not, install it now.
-## 2. Clone the project
+## 2. Clone the project from GitHub
+
+Typically you check out your fork of the project on GitHub here.
## 3. Import the project into IDEA
-Select "Import Project" and navigate to the cloned repository when prompted.
+Select the *Import Project* option (e.g. by pressing shift twice and entering "import project")
+and navigate to the cloned repository directory when prompted.
+
+### Model
+
+Chose "From existing sources" when prompted for a model.
-* Chose "From existing sources" when prompted for a model
-* At the SDK step (if you dont have a plugin SDK yet): Click `+` to add an SDK and select "IntelliJ Platform Plugin SDK"
- - Navigate to your IDEA installation and select the installation directory.
- - Afterwards select a JDK when prompted
-* At the SDK step select your Plugin SDK (if you followed the previous step select the newly created SDK)
-* The remaining options can be left at default
+### SDK Setup
+
+If you dont have a plugin SDK yet, click `+` to add an SDK and select *IntelliJ Platform Plugin SDK*
+
+1. Navigate to your IDEA installation and select the installation directory.
+2. Afterwards select a JDK when prompted
+
+Select your plugin SDK as the one to use.
+
+### Other
+
+The remaining options can be left at default
## 4. Change the project type
Open the projects iml file (it should be named `gitflow4idea.iml` by default) and replace its contents with this:
-```
+```xml
@@ -42,15 +55,15 @@ Then close and reopen the project to apply the changes.
## 5. Add git4idea dependency
-Open the module settings and navigate to modules -> gitflow4idea (or your project name here) -> dependencies.
-Click add -> "JARs or directories" and add `git4idea.jar`.
-This can be found in your IDEA installation directory under `plugins/git4idea/lib`.
-Change the scope of the added JAR to **provided**.
+1. Open the module settings and navigate to *Modules -> gitflow4idea (or your project name here)* and select the *Dependencies* tab.
+2. Click add -> "JARs or directories" and add `git4idea.jar`.
+ This can be found in your IDEA installation directory under `plugins/git4idea/lib`.
+3. Change the scope of the added JAR to **provided**.
## 6. Create a run configuration
Go to Run/Debug configurations and create a new configuration of the type `Plugin`. Under "Use classpath of module" select the project (`gitflow4idea` by default).
-Run it. A new IDEA instance should start with the plugin running.
+Click run. A new IDEA instance should start with the plugin running.
And that's it. You can now make changes to the source and run them.
From e0d071e63015944093e374120d7932ba250c8ff0 Mon Sep 17 00:00:00 2001
From: Alex Schwabe <->
Date: Fri, 4 Sep 2015 13:14:29 +0200
Subject: [PATCH 05/18] Prefixed actions with "Gitflow:"
...to make action naming consistent with other plugins and to make
searching for gitflow feature easier from the action or global search.
Other plugins typically apply a prefix (like "git:" or "perforce:") if the action is specific to a single plugin. Prefixes are only omitted when they contribute to a global action (like commit, which exists for multiple VCS).
Also added ellipsis (...) to the actions to indicate that further information is required and prompted for in the form of a dialog after the action is selected. See http://ux.stackexchange.com/questions/30420/what-are-the-rules-of-using-ellipsis-on-buttons for instance.
---
META-INF/plugin.xml | 28 +++++++++++++---------------
1 file changed, 13 insertions(+), 15 deletions(-)
diff --git a/META-INF/plugin.xml b/META-INF/plugin.xml
index dddc32a..0540850 100644
--- a/META-INF/plugin.xml
+++ b/META-INF/plugin.xml
@@ -17,23 +17,21 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
gitflow.GitflowComponent
From ba493a0f4c2ebb0bb5b467ed69c9ca616e0cd94a Mon Sep 17 00:00:00 2001
From: Alex Schwabe <->
Date: Sat, 5 Sep 2015 01:25:24 +0200
Subject: [PATCH 06/18] Issue #72: Fixed wrong prefixes
The name of the development branch was outputted twice, which shifted all other prefixes by one. Now the second prompt just gets a simple newline instead,
this seems to work on my machine (I could reproduce the issue on a local repo reliably).
---
src/gitflow/GitInitLineHandler.java | 36 +++++++++++++++++------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/src/gitflow/GitInitLineHandler.java b/src/gitflow/GitInitLineHandler.java
index 5ae5dc5..94945f2 100644
--- a/src/gitflow/GitInitLineHandler.java
+++ b/src/gitflow/GitInitLineHandler.java
@@ -4,24 +4,25 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import com.intellij.openapi.vfs.VirtualFile;
-import git4idea.commands.GitCommand;
-import git4idea.commands.GitLineHandler;
+
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
-import java.io.PrintWriter;
+
+import git4idea.commands.GitCommand;
+import git4idea.commands.GitLineHandler;
public class GitInitLineHandler extends GitLineHandler {
private BufferedWriter writer;
GitflowInitOptions _initOptions;
- public GitInitLineHandler(GitflowInitOptions initOptions,@NotNull Project project, @NotNull VirtualFile vcsRoot, @NotNull GitCommand command) {
+ public GitInitLineHandler(GitflowInitOptions initOptions, @NotNull Project project, @NotNull VirtualFile vcsRoot, @NotNull GitCommand command) {
super(project, vcsRoot, command);
- _initOptions=initOptions;
+ _initOptions = initOptions;
}
@Nullable
@@ -39,54 +40,59 @@ protected void processTerminated(final int exitCode) {
@Override
protected void onTextAvailable(String s, Key key) {
- super.onTextAvailable(s,key);
+ super.onTextAvailable(s, key);
try {
- if (s.contains("Branch name for production releases")){
+ if (s.contains("Branch name for production releases")) {
writer.write(_initOptions.getProductionBranch());
myVcs.showCommandLine(_initOptions.getProductionBranch());
writer.newLine();
writer.flush();
}
- if (s.contains("Branch name for \"next release\"") ||
- s.contains("Which branch should be used for integration of the")){
+ if (s.contains("Branch name for \"next release\"")) {
writer.write(_initOptions.getDevelopmentBranch());
myVcs.showCommandLine(_initOptions.getDevelopmentBranch());
writer.newLine();
writer.flush();
}
- if (s.contains("Feature branches")){
+
+ if (s.contains("Which branch should be used for integration of the")) {
+ writer.newLine();
+ writer.flush();
+ }
+
+ if (s.contains("Feature branches")) {
writer.write(_initOptions.getFeaturePrefix());
myVcs.showCommandLine(_initOptions.getFeaturePrefix());
writer.newLine();
writer.flush();
}
- if (s.contains("Release branches")){
+ if (s.contains("Release branches")) {
writer.write(_initOptions.getReleasePrefix());
myVcs.showCommandLine(_initOptions.getReleasePrefix());
writer.newLine();
writer.flush();
}
- if (s.contains("Hotfix branches")){
+ if (s.contains("Hotfix branches")) {
writer.write(_initOptions.getHotfixPrefix());
myVcs.showCommandLine(_initOptions.getHotfixPrefix());
writer.newLine();
writer.flush();
}
- if (s.contains("Support branches")){
+ if (s.contains("Support branches")) {
writer.write(_initOptions.getSupportPrefix());
myVcs.showCommandLine(_initOptions.getSupportPrefix());
writer.newLine();
writer.flush();
}
- if (s.contains("Version tag")){
+ if (s.contains("Version tag")) {
writer.write(_initOptions.getVersionPrefix());
myVcs.showCommandLine(_initOptions.getVersionPrefix());
writer.newLine();
writer.flush();
}
- if (s.contains("Hooks and filters")){
+ if (s.contains("Hooks and filters")) {
writer.newLine();
writer.flush();
}
From 7a28aee409d9a54ca3b88ca170b08a5ba6e2e7fc Mon Sep 17 00:00:00 2001
From: Alex Schwabe <->
Date: Sun, 6 Sep 2015 03:49:49 +0200
Subject: [PATCH 07/18] Reworked new hotfix/feature dialog
This dialog has now a combobox to select the
branch on which the new feature or hotfix branch should be based on.
The branch selection still needs some work, so the dialog is
not yet completely usable. WIP.
---
src/gitflow/Gitflow.java | 37 +++---
src/gitflow/GitflowImpl.java | 107 ++++++++++--------
src/gitflow/actions/StartHotfixAction.java | 53 +++++----
.../GitflowNewFeatureHotfixOptionsDialog.form | 45 ++++++++
.../GitflowNewFeatureHotfixOptionsDialog.java | 91 +++++++++++++++
5 files changed, 247 insertions(+), 86 deletions(-)
create mode 100644 src/gitflow/ui/GitflowNewFeatureHotfixOptionsDialog.form
create mode 100644 src/gitflow/ui/GitflowNewFeatureHotfixOptionsDialog.java
diff --git a/src/gitflow/Gitflow.java b/src/gitflow/Gitflow.java
index 3bc4560..6e52cad 100644
--- a/src/gitflow/Gitflow.java
+++ b/src/gitflow/Gitflow.java
@@ -1,16 +1,17 @@
package gitflow;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+import java.util.List;
+
import git4idea.commands.Git;
import git4idea.commands.GitCommandResult;
import git4idea.commands.GitLineHandlerListener;
import git4idea.repo.GitRemote;
import git4idea.repo.GitRepository;
-import org.jetbrains.annotations.NotNull;
-import org.jetbrains.annotations.Nullable;
/**
- *
- *
* @author Opher Vishnia / opherv.com / opherv@gmail.com
*/
public interface Gitflow extends Git {
@@ -26,23 +27,23 @@ GitCommandResult startFeature(@NotNull GitRepository repository,
@Nullable GitLineHandlerListener... listeners);
GitCommandResult finishFeature(@NotNull GitRepository repository,
- @NotNull String featureName,
- @Nullable GitLineHandlerListener... listeners);
-
- GitCommandResult publishFeature(@NotNull GitRepository repository,
@NotNull String featureName,
@Nullable GitLineHandlerListener... listeners);
- GitCommandResult pullFeature(@NotNull GitRepository repository,
+ GitCommandResult publishFeature(@NotNull GitRepository repository,
@NotNull String featureName,
- @NotNull GitRemote remote,
@Nullable GitLineHandlerListener... listeners);
- GitCommandResult trackFeature(@NotNull GitRepository repository,
+ GitCommandResult pullFeature(@NotNull GitRepository repository,
@NotNull String featureName,
@NotNull GitRemote remote,
@Nullable GitLineHandlerListener... listeners);
+ GitCommandResult trackFeature(@NotNull GitRepository repository,
+ @NotNull String featureName,
+ @NotNull GitRemote remote,
+ @Nullable GitLineHandlerListener... listeners);
+
//release
GitCommandResult startRelease(@NotNull GitRepository repository,
@@ -61,8 +62,8 @@ GitCommandResult publishRelease(@NotNull GitRepository repository,
@Nullable GitLineHandlerListener... listeners);
GitCommandResult trackRelease(@NotNull GitRepository repository,
- @NotNull String releaseName,
- @Nullable GitLineHandlerListener... listeners);
+ @NotNull String releaseName,
+ @Nullable GitLineHandlerListener... listeners);
//hotfix
@@ -71,12 +72,16 @@ GitCommandResult startHotfix(@NotNull GitRepository repository,
@Nullable GitLineHandlerListener... listeners);
GitCommandResult finishHotfix(@NotNull GitRepository repository,
- @NotNull String hotfixName,
- @NotNull String tagMessage,
- @Nullable GitLineHandlerListener... listeners);
+ @NotNull String hotfixName,
+ @NotNull String tagMessage,
+ @Nullable GitLineHandlerListener... listeners);
GitCommandResult publishHotfix(@NotNull GitRepository repository,
@NotNull String hotfixName,
@Nullable GitLineHandlerListener... listeners);
+ /**
+ * @return A list of all branches within the given repository
+ */
+ List getBranchList(GitRepository repository);
}
diff --git a/src/gitflow/GitflowImpl.java b/src/gitflow/GitflowImpl.java
index a8ed4e3..66218e2 100644
--- a/src/gitflow/GitflowImpl.java
+++ b/src/gitflow/GitflowImpl.java
@@ -1,20 +1,25 @@
package gitflow;
import com.intellij.openapi.project.Project;
-import git4idea.commands.*;
-import git4idea.repo.GitRemote;
-import git4idea.repo.GitRepository;
+import com.intellij.openapi.vfs.VirtualFile;
+
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
-import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.util.ArrayList;
+import java.util.List;
+
+import git4idea.commands.GitCommand;
+import git4idea.commands.GitCommandResult;
+import git4idea.commands.GitImpl;
+import git4idea.commands.GitLineHandler;
+import git4idea.commands.GitLineHandlerListener;
+import git4idea.repo.GitRemote;
+import git4idea.repo.GitRepository;
/**
- *
- *
* @author Opher Vishnia / opherv.com / opherv@gmail.com
*/
@@ -22,10 +27,10 @@
public class GitflowImpl extends GitImpl implements Gitflow {
//we must use reflection to add this command, since the git4idea implementation doesn't expose it
- private GitCommand GitflowCommand(){
- Method m= null;
+ private GitCommand GitflowCommand() {
+ Method m = null;
try {
- m = GitCommand.class.getDeclaredMethod("write",String.class);
+ m = GitCommand.class.getDeclaredMethod("write", String.class);
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
@@ -35,7 +40,7 @@ private GitCommand GitflowCommand(){
GitCommand command = null;
try {
- command = (GitCommand) m.invoke(null,"flow");//now its ok
+ command = (GitCommand) m.invoke(null, "flow");//now its ok
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
@@ -46,10 +51,10 @@ private GitCommand GitflowCommand(){
}
//we must use reflection to add this command, since the git4idea implementation doesn't expose it
- private static GitCommandResult run(@org.jetbrains.annotations.NotNull git4idea.commands.GitLineHandler handler){
- Method m = null;
+ private static GitCommandResult run(@org.jetbrains.annotations.NotNull git4idea.commands.GitLineHandler handler) {
+ Method m = null;
try {
- m = GitImpl.class.getDeclaredMethod("run",GitLineHandler.class);
+ m = GitImpl.class.getDeclaredMethod("run", GitLineHandler.class);
} catch (NoSuchMethodException e) {
e.printStackTrace();
}
@@ -59,7 +64,7 @@ private static GitCommandResult run(@org.jetbrains.annotations.NotNull git4idea.
GitCommandResult result = null;
try {
- result = (GitCommandResult ) m.invoke(null, handler);//now its ok
+ result = (GitCommandResult) m.invoke(null, handler);//now its ok
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
@@ -74,7 +79,7 @@ public GitCommandResult initRepo(@NotNull GitRepository repository,
GitCommandResult result;
- if(initOptions.isUseDefaults()) {
+ if (initOptions.isUseDefaults()) {
final GitLineHandler h = new GitLineHandler(repository.getProject(), repository.getRoot(), GitflowCommand());
h.setSilent(false);
h.setStdoutSuppressed(false);
@@ -83,12 +88,11 @@ public GitCommandResult initRepo(@NotNull GitRepository repository,
h.addParameters("init");
h.addParameters("-d");
- result = run(h);
- }
- else{
+ result = run(h);
+ } else {
- final GitInitLineHandler h = new GitInitLineHandler(initOptions,repository.getProject(), repository.getRoot(), GitflowCommand());
+ final GitInitLineHandler h = new GitInitLineHandler(initOptions, repository.getProject(), repository.getRoot(), GitflowCommand());
h.setSilent(false);
h.setStdoutSuppressed(false);
@@ -99,7 +103,7 @@ public GitCommandResult initRepo(@NotNull GitRepository repository,
for (GitLineHandlerListener listener : listeners) {
h.addLineListener(listener);
}
- result = run(h);
+ result = run(h);
}
@@ -129,8 +133,8 @@ public GitCommandResult startFeature(@NotNull GitRepository repository,
}
public GitCommandResult finishFeature(@NotNull GitRepository repository,
- @NotNull String featureName,
- @Nullable GitLineHandlerListener... listeners) {
+ @NotNull String featureName,
+ @Nullable GitLineHandlerListener... listeners) {
final GitLineHandler h = new GitLineHandler(repository.getProject(), repository.getRoot(), GitflowCommand());
setUrl(h, repository);
@@ -157,8 +161,8 @@ public GitCommandResult finishFeature(@NotNull GitRepository repository,
public GitCommandResult publishFeature(@NotNull GitRepository repository,
- @NotNull String featureName,
- @Nullable GitLineHandlerListener... listeners) {
+ @NotNull String featureName,
+ @Nullable GitLineHandlerListener... listeners) {
final GitLineHandler h = new GitLineHandler(repository.getProject(), repository.getRoot(), GitflowCommand());
setUrl(h, repository);
h.setSilent(false);
@@ -177,9 +181,9 @@ public GitCommandResult publishFeature(@NotNull GitRepository repository,
// feature pull seems to be kind of useless. see
// http://stackoverflow.com/questions/18412750/why-doesnt-git-flow-feature-pull-track
public GitCommandResult pullFeature(@NotNull GitRepository repository,
- @NotNull String featureName,
- @NotNull GitRemote remote,
- @Nullable GitLineHandlerListener... listeners) {
+ @NotNull String featureName,
+ @NotNull GitRemote remote,
+ @Nullable GitLineHandlerListener... listeners) {
final GitLineHandler h = new GitLineHandler(repository.getProject(), repository.getRoot(), GitflowCommand());
setUrl(h, repository);
h.setSilent(false);
@@ -195,9 +199,9 @@ public GitCommandResult pullFeature(@NotNull GitRepository repository,
}
public GitCommandResult trackFeature(@NotNull GitRepository repository,
- @NotNull String featureName,
- @NotNull GitRemote remote,
- @Nullable GitLineHandlerListener... listeners) {
+ @NotNull String featureName,
+ @NotNull GitRemote remote,
+ @Nullable GitLineHandlerListener... listeners) {
final GitLineHandler h = new GitLineHandler(repository.getProject(), repository.getRoot(), GitflowCommand());
setUrl(h, repository);
h.setSilent(false);
@@ -248,14 +252,13 @@ public GitCommandResult finishRelease(@NotNull GitRepository repository,
if (GitflowConfigurable.releaseFetchOrigin(repository.getProject())) {
h.addParameters("-F");
}
- if(GitflowConfigurable.pushOnReleaseFinish(repository.getProject())) {
+ if (GitflowConfigurable.pushOnReleaseFinish(repository.getProject())) {
h.addParameters("-p");
}
if (GitflowConfigurable.dontTagRelease(repository.getProject())) {
h.addParameters("-n");
- }
- else{
+ } else {
h.addParameters("-m");
h.addParameters(tagMessage);
}
@@ -288,8 +291,8 @@ public GitCommandResult publishRelease(@NotNull GitRepository repository,
}
public GitCommandResult trackRelease(@NotNull GitRepository repository,
- @NotNull String releaseName,
- @Nullable GitLineHandlerListener... listeners) {
+ @NotNull String releaseName,
+ @Nullable GitLineHandlerListener... listeners) {
final GitLineHandler h = new GitLineHandler(repository.getProject(), repository.getRoot(), GitflowCommand());
setUrl(h, repository);
h.setSilent(false);
@@ -308,8 +311,8 @@ public GitCommandResult trackRelease(@NotNull GitRepository repository,
//hotfix
public GitCommandResult startHotfix(@NotNull GitRepository repository,
- @NotNull String hotfixName,
- @Nullable GitLineHandlerListener... listeners) {
+ @NotNull String hotfixName,
+ @Nullable GitLineHandlerListener... listeners) {
final GitLineHandler h = new GitLineHandler(repository.getProject(), repository.getRoot(), GitflowCommand());
h.setSilent(false);
@@ -327,9 +330,9 @@ public GitCommandResult startHotfix(@NotNull GitRepository repository,
}
public GitCommandResult finishHotfix(@NotNull GitRepository repository,
- @NotNull String hotfixName,
- @NotNull String tagMessage,
- @Nullable GitLineHandlerListener... listeners) {
+ @NotNull String hotfixName,
+ @NotNull String tagMessage,
+ @Nullable GitLineHandlerListener... listeners) {
final GitLineHandler h = new GitLineHandler(repository.getProject(), repository.getRoot(), GitflowCommand());
setUrl(h, repository);
h.setSilent(false);
@@ -346,8 +349,7 @@ public GitCommandResult finishHotfix(@NotNull GitRepository repository,
if (GitflowConfigurable.dontTagHotfix(repository.getProject())) {
h.addParameters("-n");
- }
- else{
+ } else {
h.addParameters("-m");
h.addParameters(tagMessage);
}
@@ -378,13 +380,28 @@ public GitCommandResult publishHotfix(@NotNull GitRepository repository,
return run(h);
}
- private void setUrl (GitLineHandler h, GitRepository repository){
- ArrayList remotes = new ArrayList(repository.getRemotes());
+ @Override
+ public List getBranchList(GitRepository repository) {
+ final Project project = repository.getProject();
+ final VirtualFile root = repository.getRoot();
+
+ GitCommandResult commandResult = run(new GitLineHandler(project, root, GitCommand.BRANCH));
+ List result = new ArrayList<>(commandResult.getOutput().size());
+ for (String line : commandResult.getOutput()) {
+ result.add(line.replace("*", "").trim());
+ }
+
+ return result;
+ }
+
+ private void setUrl(GitLineHandler h, GitRepository repository) {
+ ArrayList remotes = new ArrayList<>(repository.getRemotes());
//make sure a remote repository is available
- if (!remotes.isEmpty()){
+ if (!remotes.isEmpty()) {
h.setUrl(remotes.iterator().next().getFirstUrl());
}
}
+
}
diff --git a/src/gitflow/actions/StartHotfixAction.java b/src/gitflow/actions/StartHotfixAction.java
index e898f21..8f389f5 100644
--- a/src/gitflow/actions/StartHotfixAction.java
+++ b/src/gitflow/actions/StartHotfixAction.java
@@ -3,11 +3,13 @@
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
-import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.ui.DialogWrapper;
+
+import org.jetbrains.annotations.NotNull;
+
import git4idea.commands.GitCommandResult;
-import git4idea.validators.GitNewBranchNameValidator;
+import gitflow.ui.GitflowNewFeatureHotfixOptionsDialog;
import gitflow.ui.NotifyUtil;
-import org.jetbrains.annotations.NotNull;
public class StartHotfixAction extends GitflowAction {
@@ -19,34 +21,35 @@ public class StartHotfixAction extends GitflowAction {
public void actionPerformed(AnActionEvent e) {
super.actionPerformed(e);
- final String hotfixName = Messages.showInputDialog(myProject, "Enter the name of the new hotfix:", "New Hotfix", Messages.getQuestionIcon(), "",
- GitNewBranchNameValidator.newInstance(repos));
- final GitflowErrorsListener errorLineHandler = new GitflowErrorsListener(myProject);
+ GitflowNewFeatureHotfixOptionsDialog dialog =
+ new GitflowNewFeatureHotfixOptionsDialog(myGitflow, repo, myProject, "hotfix");
+ dialog.show();
- //must insert hotfix name
- if (hotfixName!=null && !hotfixName.isEmpty()){
- new Task.Backgroundable(myProject,"Starting hotfix "+hotfixName,false){
- @Override
- public void run(@NotNull ProgressIndicator indicator) {
- GitCommandResult result = myGitflow.startHotfix(repo, hotfixName, errorLineHandler);
+ if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) return;
- if (result.success()) {
- String startedHotfixMessage = String.format("A new hotfix '%s%s' was created, based on '%s'", hotfixPrefix, hotfixName, masterBranch);
- NotifyUtil.notifySuccess(myProject, hotfixName, startedHotfixMessage);
- }
- else {
- NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details");
- }
+ final String hotfixBranchName = dialog.getNewBranchName();
+ final String baseBranchName = dialog.getBaseBranchName();
- repo.update();
+ new Task.Backgroundable(myProject, "Starting hotfix " + hotfixBranchName, false) {
+ @Override
+ public void run(@NotNull ProgressIndicator indicator) {
+ createHotfixBranch(baseBranchName, hotfixBranchName);
+ }
+ }.queue();
+ }
- }
- }.queue();
+ private void createHotfixBranch(String baseBranchName, String hotfixBranchName) {
+ GitflowErrorsListener errorListener = new GitflowErrorsListener(myProject);
+ GitCommandResult result = myGitflow.startHotfix(repo, hotfixBranchName, errorListener);
- }
- else{
- Messages.showWarningDialog(myProject, "You must provide a name for the hotfix", "Whoops");
+ if (result.success()) {
+ String startedHotfixMessage = String.format("A new hotfix '%s%s' was created, based on '%s'",
+ hotfixPrefix, hotfixBranchName, masterBranch);
+ NotifyUtil.notifySuccess(myProject, hotfixBranchName, startedHotfixMessage);
+ } else {
+ NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details");
}
+ repo.update();
}
}
\ No newline at end of file
diff --git a/src/gitflow/ui/GitflowNewFeatureHotfixOptionsDialog.form b/src/gitflow/ui/GitflowNewFeatureHotfixOptionsDialog.form
new file mode 100644
index 0000000..3399cf2
--- /dev/null
+++ b/src/gitflow/ui/GitflowNewFeatureHotfixOptionsDialog.form
@@ -0,0 +1,45 @@
+
+
diff --git a/src/gitflow/ui/GitflowNewFeatureHotfixOptionsDialog.java b/src/gitflow/ui/GitflowNewFeatureHotfixOptionsDialog.java
new file mode 100644
index 0000000..51754da
--- /dev/null
+++ b/src/gitflow/ui/GitflowNewFeatureHotfixOptionsDialog.java
@@ -0,0 +1,91 @@
+package gitflow.ui;
+
+import com.intellij.openapi.project.Project;
+import com.intellij.openapi.ui.DialogWrapper;
+import com.intellij.openapi.ui.ValidationInfo;
+
+import java.util.List;
+
+import javax.swing.*;
+
+import git4idea.repo.GitRepository;
+import gitflow.Gitflow;
+
+/**
+ * This dialog gets displayed when the user selected the option to create a new feature or hotfix.
+ * It prompts the user to enter a name for the new branch and (optionally) to select a branch on
+ * which the new branch is based.
+ *
+ * The default selection for the base branch is - new feature: the development branch
+ * - new hotfix: the release branch
+ *
+ * These are always selected when the dialog is opened to allow the user to skip branch selection,
+ * given that this is the common use-case.
+ */
+public class GitflowNewFeatureHotfixOptionsDialog extends DialogWrapper {
+
+ private JPanel contentPane;
+ private JTextField branchNameTextField;
+ private JComboBox branchFromCombo;
+ private JLabel branchNameLabel;
+
+ private GitRepository repository;
+ private Gitflow gitflow;
+
+ /**
+ * @param label The label/type of the dialog, for example "hotfix" or "feature". Used for the
+ */
+ public GitflowNewFeatureHotfixOptionsDialog(Gitflow gitflow, GitRepository repository, Project project, String label) {
+ super(project, false);
+ this.gitflow = gitflow;
+ this.repository = repository;
+
+ init();
+ setTitle("New " + label + "...");
+ branchNameLabel.setText(String.format("Enter a name for the new %s...", label));
+ setModal(true);
+
+ branchFromCombo.setModel(createBranchComboModel());
+ }
+
+ @Override
+ protected JComponent createCenterPanel() {
+ return contentPane;
+ }
+
+ @Override
+ public JComponent getPreferredFocusedComponent() {
+ return branchNameTextField;
+ }
+
+ private ComboBoxModel createBranchComboModel() {
+ List branchList = gitflow.getBranchList(repository);
+ String[] branchListArray = branchList.toArray(new String[branchList.size()]);
+ return new DefaultComboBoxModel<>(branchListArray);
+ }
+
+ @Override
+ protected ValidationInfo doValidate() {
+ boolean isBranchNameSpecified = branchNameTextField.getText().trim().length() > 0;
+ if (!isBranchNameSpecified) {
+ return new ValidationInfo("No branch name specified", branchNameTextField);
+ } else {
+ return null;
+ }
+ }
+
+ /**
+ * @return The name of the new branch as specified by the user
+ */
+ public String getNewBranchName() {
+ return branchNameTextField.getText().trim();
+ }
+
+ /**
+ * @return The name of the base branch (the branch on which the new hotfix or feature should be
+ * based on)
+ */
+ public String getBaseBranchName() {
+ return "";
+ }
+}
From 67100ef83af8319b79f00b8f92db8507352ee706 Mon Sep 17 00:00:00 2001
From: Alex Schwabe <->
Date: Mon, 7 Sep 2015 16:01:23 +0200
Subject: [PATCH 08/18] Implemented new start feature and start hotfix dialog
---
src/gitflow/Gitflow.java | 2 +
src/gitflow/GitflowImpl.java | 12 ++-
src/gitflow/actions/StartFeatureAction.java | 52 +++++------
src/gitflow/actions/StartHotfixAction.java | 16 ++--
...og.form => AbstractBranchStartDialog.form} | 2 +-
...og.java => AbstractBranchStartDialog.java} | 86 +++++++++++--------
src/gitflow/ui/GitflowStartFeatureDialog.java | 24 ++++++
src/gitflow/ui/GitflowStartHotfixDialog.java | 24 ++++++
8 files changed, 147 insertions(+), 71 deletions(-)
rename src/gitflow/ui/{GitflowNewFeatureHotfixOptionsDialog.form => AbstractBranchStartDialog.form} (96%)
rename src/gitflow/ui/{GitflowNewFeatureHotfixOptionsDialog.java => AbstractBranchStartDialog.java} (60%)
create mode 100644 src/gitflow/ui/GitflowStartFeatureDialog.java
create mode 100644 src/gitflow/ui/GitflowStartHotfixDialog.java
diff --git a/src/gitflow/Gitflow.java b/src/gitflow/Gitflow.java
index 6e52cad..755db3f 100644
--- a/src/gitflow/Gitflow.java
+++ b/src/gitflow/Gitflow.java
@@ -24,6 +24,7 @@ public GitCommandResult initRepo(@NotNull GitRepository repository,
GitCommandResult startFeature(@NotNull GitRepository repository,
@NotNull String featureName,
+ @Nullable String baseBranch,
@Nullable GitLineHandlerListener... listeners);
GitCommandResult finishFeature(@NotNull GitRepository repository,
@@ -69,6 +70,7 @@ GitCommandResult trackRelease(@NotNull GitRepository repository,
GitCommandResult startHotfix(@NotNull GitRepository repository,
@NotNull String hotfixName,
+ @Nullable String baseBranch,
@Nullable GitLineHandlerListener... listeners);
GitCommandResult finishHotfix(@NotNull GitRepository repository,
diff --git a/src/gitflow/GitflowImpl.java b/src/gitflow/GitflowImpl.java
index 66218e2..94c2744 100644
--- a/src/gitflow/GitflowImpl.java
+++ b/src/gitflow/GitflowImpl.java
@@ -115,6 +115,7 @@ public GitCommandResult initRepo(@NotNull GitRepository repository,
public GitCommandResult startFeature(@NotNull GitRepository repository,
@NotNull String featureName,
+ @Nullable String baseBranch,
@Nullable GitLineHandlerListener... listeners) {
final GitLineHandler h = new GitLineHandler(repository.getProject(), repository.getRoot(), GitflowCommand());
h.setSilent(false);
@@ -126,6 +127,10 @@ public GitCommandResult startFeature(@NotNull GitRepository repository,
}
h.addParameters(featureName);
+ if (baseBranch != null) {
+ h.addParameters(baseBranch);
+ }
+
for (GitLineHandlerListener listener : listeners) {
h.addLineListener(listener);
}
@@ -312,6 +317,7 @@ public GitCommandResult trackRelease(@NotNull GitRepository repository,
public GitCommandResult startHotfix(@NotNull GitRepository repository,
@NotNull String hotfixName,
+ @Nullable String baseBranch,
@Nullable GitLineHandlerListener... listeners) {
final GitLineHandler h = new GitLineHandler(repository.getProject(), repository.getRoot(), GitflowCommand());
h.setSilent(false);
@@ -323,6 +329,10 @@ public GitCommandResult startHotfix(@NotNull GitRepository repository,
}
h.addParameters(hotfixName);
+ if (baseBranch != null) {
+ h.addParameters(baseBranch);
+ }
+
for (GitLineHandlerListener listener : listeners) {
h.addLineListener(listener);
}
@@ -390,7 +400,7 @@ public List getBranchList(GitRepository repository) {
for (String line : commandResult.getOutput()) {
result.add(line.replace("*", "").trim());
}
-
+
return result;
}
diff --git a/src/gitflow/actions/StartFeatureAction.java b/src/gitflow/actions/StartFeatureAction.java
index d08f02c..5d00507 100644
--- a/src/gitflow/actions/StartFeatureAction.java
+++ b/src/gitflow/actions/StartFeatureAction.java
@@ -3,51 +3,51 @@
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.progress.ProgressIndicator;
import com.intellij.openapi.progress.Task;
-import com.intellij.openapi.ui.Messages;
+import com.intellij.openapi.ui.DialogWrapper;
+
+import org.jetbrains.annotations.NotNull;
+
import git4idea.commands.GitCommandResult;
-import git4idea.validators.GitNewBranchNameValidator;
+import gitflow.ui.GitflowStartFeatureDialog;
import gitflow.ui.NotifyUtil;
-import org.jetbrains.annotations.NotNull;
public class StartFeatureAction extends GitflowAction {
-
StartFeatureAction() {
super("Start Feature");
}
@Override
public void actionPerformed(AnActionEvent e) {
- //set up context variables
super.actionPerformed(e);
- final String featureName = Messages.showInputDialog(myProject, "Enter the name of new feature:", "New Feature", Messages.getQuestionIcon(), "",
- GitNewBranchNameValidator.newInstance(repos));
-
- if (featureName!=null && !featureName.isEmpty()){
- new Task.Backgroundable(myProject,"Starting feature "+featureName,false){
- @Override
- public void run(@NotNull ProgressIndicator indicator) {
- GitCommandResult result = myGitflow.startFeature(repo,featureName,new GitflowErrorsListener(myProject));
+ GitflowStartFeatureDialog dialog = new GitflowStartFeatureDialog(myGitflow, repo, myProject);
+ dialog.show();
+ if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) return;
- if (result.success()) {
- String startedFeatureMessage = String.format("A new branch '%s%s' was created, based on '%s'", featurePrefix, featureName, developBranch);
- NotifyUtil.notifySuccess(myProject, featureName, startedFeatureMessage);
- }
- else {
- NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details");
- }
+ final String featureName = dialog.getNewBranchName();
+ final String baseBranchName = dialog.getBaseBranchName();
- repo.update();
+ new Task.Backgroundable(myProject, "Starting feature " + featureName, false) {
+ @Override
+ public void run(@NotNull ProgressIndicator indicator) {
+ createFeatureBranch(baseBranchName, featureName);
+ }
+ }.queue();
+ }
- }
- }.queue();
+ private void createFeatureBranch(String baseBranchName, String featureName) {
+ GitflowErrorsListener errorListener = new GitflowErrorsListener(myProject);
+ GitCommandResult result = myGitflow.startFeature(repo, featureName, baseBranchName, errorListener);
- }
- else{
- Messages.showWarningDialog(myProject, "You must provide a name for the feature", "Whoops");
+ if (result.success()) {
+ String startedFeatureMessage = String.format("A new branch '%s%s' was created, based on '%s'", featurePrefix, featureName, baseBranchName);
+ NotifyUtil.notifySuccess(myProject, featureName, startedFeatureMessage);
+ } else {
+ NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details");
}
+ repo.update();
}
}
\ No newline at end of file
diff --git a/src/gitflow/actions/StartHotfixAction.java b/src/gitflow/actions/StartHotfixAction.java
index 8f389f5..95780aa 100644
--- a/src/gitflow/actions/StartHotfixAction.java
+++ b/src/gitflow/actions/StartHotfixAction.java
@@ -8,9 +8,10 @@
import org.jetbrains.annotations.NotNull;
import git4idea.commands.GitCommandResult;
-import gitflow.ui.GitflowNewFeatureHotfixOptionsDialog;
+import gitflow.ui.GitflowStartHotfixDialog;
import gitflow.ui.NotifyUtil;
+
public class StartHotfixAction extends GitflowAction {
StartHotfixAction() {
@@ -21,30 +22,29 @@ public class StartHotfixAction extends GitflowAction {
public void actionPerformed(AnActionEvent e) {
super.actionPerformed(e);
- GitflowNewFeatureHotfixOptionsDialog dialog =
- new GitflowNewFeatureHotfixOptionsDialog(myGitflow, repo, myProject, "hotfix");
+ GitflowStartHotfixDialog dialog = new GitflowStartHotfixDialog(myGitflow, repo, myProject);
dialog.show();
if (dialog.getExitCode() != DialogWrapper.OK_EXIT_CODE) return;
- final String hotfixBranchName = dialog.getNewBranchName();
+ final String hotfixName = dialog.getNewBranchName();
final String baseBranchName = dialog.getBaseBranchName();
- new Task.Backgroundable(myProject, "Starting hotfix " + hotfixBranchName, false) {
+ new Task.Backgroundable(myProject, "Starting hotfix " + hotfixName, false) {
@Override
public void run(@NotNull ProgressIndicator indicator) {
- createHotfixBranch(baseBranchName, hotfixBranchName);
+ createHotfixBranch(baseBranchName, hotfixName);
}
}.queue();
}
private void createHotfixBranch(String baseBranchName, String hotfixBranchName) {
GitflowErrorsListener errorListener = new GitflowErrorsListener(myProject);
- GitCommandResult result = myGitflow.startHotfix(repo, hotfixBranchName, errorListener);
+ GitCommandResult result = myGitflow.startHotfix(repo, hotfixBranchName, baseBranchName, errorListener);
if (result.success()) {
String startedHotfixMessage = String.format("A new hotfix '%s%s' was created, based on '%s'",
- hotfixPrefix, hotfixBranchName, masterBranch);
+ hotfixPrefix, hotfixBranchName, baseBranchName);
NotifyUtil.notifySuccess(myProject, hotfixBranchName, startedHotfixMessage);
} else {
NotifyUtil.notifyError(myProject, "Error", "Please have a look at the Version Control console for more details");
diff --git a/src/gitflow/ui/GitflowNewFeatureHotfixOptionsDialog.form b/src/gitflow/ui/AbstractBranchStartDialog.form
similarity index 96%
rename from src/gitflow/ui/GitflowNewFeatureHotfixOptionsDialog.form
rename to src/gitflow/ui/AbstractBranchStartDialog.form
index 3399cf2..44c0611 100644
--- a/src/gitflow/ui/GitflowNewFeatureHotfixOptionsDialog.form
+++ b/src/gitflow/ui/AbstractBranchStartDialog.form
@@ -1,5 +1,5 @@
-