diff --git a/META-INF/plugin.xml b/META-INF/plugin.xml index 9e05ee5..35490df 100644 --- a/META-INF/plugin.xml +++ b/META-INF/plugin.xml @@ -2,14 +2,14 @@ Git Flow Integration Gitflow Git Flow Integration - 0.4 + 0.4.1 VCS Integration Opher Vishnia com.intellij.modules.vcs Git4Idea - + diff --git a/src/gitflow/GitInitLineHandler.java b/src/gitflow/GitInitLineHandler.java new file mode 100644 index 0000000..5ae5dc5 --- /dev/null +++ b/src/gitflow/GitInitLineHandler.java @@ -0,0 +1,100 @@ +package gitflow; + +import com.intellij.execution.ExecutionException; +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; + + +public class GitInitLineHandler extends GitLineHandler { + private BufferedWriter writer; + GitflowInitOptions _initOptions; + + public GitInitLineHandler(GitflowInitOptions initOptions,@NotNull Project project, @NotNull VirtualFile vcsRoot, @NotNull GitCommand command) { + super(project, vcsRoot, command); + _initOptions=initOptions; + } + + @Nullable + @Override + protected Process startProcess() throws ExecutionException { + Process p = super.startProcess(); + writer = new BufferedWriter(new OutputStreamWriter(p.getOutputStream())); + return p; + } + + protected void processTerminated(final int exitCode) { + super.processTerminated(exitCode); + } + + + @Override + protected void onTextAvailable(String s, Key key) { + super.onTextAvailable(s,key); + try { + 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")){ + + writer.write(_initOptions.getDevelopmentBranch()); + myVcs.showCommandLine(_initOptions.getDevelopmentBranch()); + 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")){ + writer.write(_initOptions.getReleasePrefix()); + myVcs.showCommandLine(_initOptions.getReleasePrefix()); + writer.newLine(); + writer.flush(); + } + if (s.contains("Hotfix branches")){ + writer.write(_initOptions.getHotfixPrefix()); + myVcs.showCommandLine(_initOptions.getHotfixPrefix()); + writer.newLine(); + writer.flush(); + } + if (s.contains("Support branches")){ + writer.write(_initOptions.getSupportPrefix()); + myVcs.showCommandLine(_initOptions.getSupportPrefix()); + writer.newLine(); + writer.flush(); + } + if (s.contains("Version tag")){ + writer.write(_initOptions.getVersionPrefix()); + myVcs.showCommandLine(_initOptions.getVersionPrefix()); + writer.newLine(); + writer.flush(); + } + if (s.contains("Hooks and filters")){ + writer.newLine(); + writer.flush(); + } + + + } catch (IOException e) { + e.printStackTrace(); + } + } + +} diff --git a/src/gitflow/GitflowImpl.java b/src/gitflow/GitflowImpl.java index f65c98a..a8ed4e3 100644 --- a/src/gitflow/GitflowImpl.java +++ b/src/gitflow/GitflowImpl.java @@ -7,6 +7,7 @@ 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; @@ -70,40 +71,41 @@ private static GitCommandResult run(@org.jetbrains.annotations.NotNull git4idea. public GitCommandResult initRepo(@NotNull GitRepository repository, GitflowInitOptions initOptions, @Nullable GitLineHandlerListener... listeners) { - if(!initOptions.isUseDefaults()) { - configureBranches(initOptions, repository.getProject()); - } - final GitLineHandler h = new GitLineHandler(repository.getProject(), repository.getRoot(), GitflowCommand()); - h.setSilent(false); + GitCommandResult result; - h.addParameters("init"); - h.addParameters("-d"); + if(initOptions.isUseDefaults()) { + final GitLineHandler h = new GitLineHandler(repository.getProject(), repository.getRoot(), GitflowCommand()); + h.setSilent(false); + h.setStdoutSuppressed(false); + h.setStderrSuppressed(false); - for (GitLineHandlerListener listener : listeners) { - h.addLineListener(listener); + h.addParameters("init"); + h.addParameters("-d"); + + result = run(h); } - GitCommandResult result = run(h); + else{ + - if(result.success() && !initOptions.isUseDefaults()) { - configurePrefixes(initOptions, repository.getProject()); + final GitInitLineHandler h = new GitInitLineHandler(initOptions,repository.getProject(), repository.getRoot(), GitflowCommand()); + + h.setSilent(false); + h.setStdoutSuppressed(false); + h.setStderrSuppressed(false); + + h.addParameters("init"); + + for (GitLineHandlerListener listener : listeners) { + h.addLineListener(listener); + } + result = run(h); } - return result; - } - private void configureBranches(GitflowInitOptions initOptions, Project project) { - GitflowConfigUtil.setMasterBranch(project, initOptions.getProductionBranch()); - GitflowConfigUtil.setDevelopBranch(project, initOptions.getDevelopmentBranch()); + return result; } - private void configurePrefixes(GitflowInitOptions initOptions, Project project) { - GitflowConfigUtil.setFeaturePrefix(project, initOptions.getFeaturePrefix()); - GitflowConfigUtil.setReleasePrefix(project, initOptions.getReleasePrefix()); - GitflowConfigUtil.setHotfixPrefix(project, initOptions.getHotfixPrefix()); - GitflowConfigUtil.setSupportPrefix(project, initOptions.getSupportPrefix()); - GitflowConfigUtil.setVersionPrefix(project, initOptions.getVersionPrefix()); - } //feature diff --git a/src/gitflow/ui/GitflowInitOptionsDialog.form b/src/gitflow/ui/GitflowInitOptionsDialog.form index dfcbbed..5d1e61b 100644 --- a/src/gitflow/ui/GitflowInitOptionsDialog.form +++ b/src/gitflow/ui/GitflowInitOptionsDialog.form @@ -3,7 +3,7 @@ - + @@ -23,6 +23,7 @@ + @@ -54,6 +55,7 @@ + diff --git a/src/gitflow/ui/GitflowWidget.java b/src/gitflow/ui/GitflowWidget.java index ff4555d..29b101e 100644 --- a/src/gitflow/ui/GitflowWidget.java +++ b/src/gitflow/ui/GitflowWidget.java @@ -74,17 +74,17 @@ public WidgetPresentation getPresentation(@NotNull PlatformType type) { @Override public void selectionChanged(FileEditorManagerEvent event) { - update(); + //update(); } @Override public void fileOpened(FileEditorManager source, VirtualFile file) { - update(); + //update(); } @Override public void fileClosed(FileEditorManager source, VirtualFile file) { - update(); + //update(); } @Override