Skip to content

Commit

Permalink
Merge branch 'release/0.4.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
OpherV committed Mar 1, 2015
2 parents 2549def + 4100530 commit 43a00ee
Show file tree
Hide file tree
Showing 5 changed files with 134 additions and 30 deletions.
4 changes: 2 additions & 2 deletions META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@
<name>Git Flow Integration</name>
<id>Gitflow</id>
<description>Git Flow Integration</description>
<version>0.4</version>
<version>0.4.1</version>
<category>VCS Integration</category>
<vendor url="http://www.opherv.com">Opher Vishnia</vendor>

<depends>com.intellij.modules.vcs</depends>
<depends>Git4Idea</depends>

<idea-version since-build="129" until-build="139.999999"/>
<idea-version since-build="129" until-build="140.999999"/>

<actions>
<action id="Gitflow.InitRepo" class="gitflow.actions.InitRepoAction" text="Initialize Gitflow Repository"></action>
Expand Down
100 changes: 100 additions & 0 deletions src/gitflow/GitInitLineHandler.java
Original file line number Diff line number Diff line change
@@ -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();
}
}

}
50 changes: 26 additions & 24 deletions src/gitflow/GitflowImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion src/gitflow/ui/GitflowInitOptionsDialog.form
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<grid id="cbd77" binding="contentPane" layout-manager="GridLayoutManager" row-count="1" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="10" left="10" bottom="10" right="10"/>
<constraints>
<xy x="48" y="54" width="469" height="297"/>
<xy x="48" y="54" width="484" height="341"/>
</constraints>
<properties/>
<border type="none"/>
Expand All @@ -23,6 +23,7 @@
</grid>
</constraints>
<properties>
<editable value="true"/>
<enabled value="false"/>
</properties>
</component>
Expand Down Expand Up @@ -54,6 +55,7 @@
</grid>
</constraints>
<properties>
<editable value="true"/>
<enabled value="false"/>
</properties>
</component>
Expand Down
6 changes: 3 additions & 3 deletions src/gitflow/ui/GitflowWidget.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 43a00ee

Please sign in to comment.