Skip to content

Commit

Permalink
implement #48, --keepremote flag
Browse files Browse the repository at this point in the history
  • Loading branch information
OpherV committed Aug 5, 2014
1 parent 69018f9 commit 037d927
Show file tree
Hide file tree
Showing 4 changed files with 102 additions and 37 deletions.
49 changes: 35 additions & 14 deletions src/gitflow/GitflowConfigurable.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
*/

public class GitflowConfigurable implements Configurable {
public static final String GITFLOW_FEATURE_KEEP_REMOTE = "Gitflow.featureKeepRemote";

public static final String GITFLOW_PUSH_ON_FINISH_RELEASE = "Gitflow.pushOnFinishRelease";
public static final String GITFLOW_PUSH_ON_FINISH_HOTFIX = "Gitflow.pushOnFinishHotfix";
public static final String GITFLOW_DONT_TAG_RELEASE = "Gitflow.dontTagRelease";
Expand All @@ -36,22 +38,23 @@ public GitflowConfigurable(Project project)
this.project = project;
}

/* feature */

public static boolean featureKeepRemote(Project project) {
return PropertiesComponent.getInstance(project).getBoolean(GitflowConfigurable.GITFLOW_FEATURE_KEEP_REMOTE, false);
}

/* release */

public static boolean pushOnReleaseFinish(Project project) {
return PropertiesComponent.getInstance(project).getBoolean(GitflowConfigurable.GITFLOW_PUSH_ON_FINISH_RELEASE, false);
}

public static boolean pushOnHotfixFinish(Project project) {
return PropertiesComponent.getInstance(project).getBoolean(GitflowConfigurable.GITFLOW_PUSH_ON_FINISH_HOTFIX, false);
}

public static boolean dontTagRelease(Project project) {
return PropertiesComponent.getInstance(project).getBoolean(GitflowConfigurable.GITFLOW_DONT_TAG_RELEASE, false);
}

public static boolean dontTagHotfix(Project project) {
return PropertiesComponent.getInstance(project).getBoolean(GitflowConfigurable.GITFLOW_DONT_TAG_HOTFIX, false);
}

/* finish release custom commit message */

public static boolean useCustomTagCommitMessage(Project project) {
Expand All @@ -67,6 +70,17 @@ public static String getCustomTagCommitMessage(Project project) {
}
}

/*hotfix*/

public static boolean pushOnHotfixFinish(Project project) {
return PropertiesComponent.getInstance(project).getBoolean(GitflowConfigurable.GITFLOW_PUSH_ON_FINISH_HOTFIX, false);
}

public static boolean dontTagHotfix(Project project) {
return PropertiesComponent.getInstance(project).getBoolean(GitflowConfigurable.GITFLOW_DONT_TAG_HOTFIX, false);
}


/* finish hotfix custom commit message */
public static boolean useCustomHotfixTagCommitMessage(Project project) {
return PropertiesComponent.getInstance(project).getBoolean(GitflowConfigurable.GITFLOW_USE_CUSTOM_HOTFIX_TAG_COMMIT_MESSAGE, false);
Expand Down Expand Up @@ -103,39 +117,46 @@ public JComponent createComponent() {

@Override
public boolean isModified() {
return PropertiesComponent.getInstance(project).getBoolean(GITFLOW_PUSH_ON_FINISH_RELEASE, false) != gitflowOptionsForm.isPushOnFinishRelease() ||
PropertiesComponent.getInstance(project).getBoolean(GITFLOW_PUSH_ON_FINISH_HOTFIX, false) != gitflowOptionsForm.isPushOnFinishHotfix() ||
return PropertiesComponent.getInstance(project).getBoolean(GITFLOW_FEATURE_KEEP_REMOTE, false) != gitflowOptionsForm.isFeatureKeepRemote() ||

PropertiesComponent.getInstance(project).getBoolean(GITFLOW_PUSH_ON_FINISH_RELEASE, false) != gitflowOptionsForm.isPushOnFinishRelease() ||
PropertiesComponent.getInstance(project).getBoolean(GITFLOW_DONT_TAG_RELEASE, false) != gitflowOptionsForm.isDontTagRelease() ||
PropertiesComponent.getInstance(project).getBoolean(GITFLOW_DONT_TAG_HOTFIX, false) != gitflowOptionsForm.isDontTagHotfix() ||
PropertiesComponent.getInstance(project).getBoolean(GITFLOW_USE_CUSTOM_TAG_COMMIT_MESSAGE, false) != gitflowOptionsForm.isUseCustomTagCommitMessage() ||
PropertiesComponent.getInstance(project).getValue(GITFLOW_CUSTOM_TAG_COMMIT_MESSAGE, DEFAULT_TAG_COMMIT_MESSAGE).equals(gitflowOptionsForm.getCustomTagCommitMessage())==false ||

PropertiesComponent.getInstance(project).getBoolean(GITFLOW_PUSH_ON_FINISH_HOTFIX, false) != gitflowOptionsForm.isPushOnFinishHotfix() ||
PropertiesComponent.getInstance(project).getBoolean(GITFLOW_DONT_TAG_HOTFIX, false) != gitflowOptionsForm.isDontTagHotfix() ||
PropertiesComponent.getInstance(project).getBoolean(GITFLOW_USE_CUSTOM_HOTFIX_TAG_COMMIT_MESSAGE, false) != gitflowOptionsForm.isUseCustomHotfixComitMessage() ||
PropertiesComponent.getInstance(project).getValue(GITFLOW_CUSTOM_HOTFIX_TAG_COMMIT_MESSAGE, DEFAULT_TAG_HOTFIX_COMMIT_MESSAGE).equals(gitflowOptionsForm.getCustomHotfixCommitMessage())==false
;
}

@Override
public void apply() throws ConfigurationException {
PropertiesComponent.getInstance(project).setValue(GITFLOW_FEATURE_KEEP_REMOTE, Boolean.toString(gitflowOptionsForm.isFeatureKeepRemote()));

PropertiesComponent.getInstance(project).setValue(GITFLOW_PUSH_ON_FINISH_RELEASE, Boolean.toString(gitflowOptionsForm.isPushOnFinishRelease()));
PropertiesComponent.getInstance(project).setValue(GITFLOW_PUSH_ON_FINISH_HOTFIX, Boolean.toString(gitflowOptionsForm.isPushOnFinishHotfix()));
PropertiesComponent.getInstance(project).setValue(GITFLOW_DONT_TAG_RELEASE, Boolean.toString(gitflowOptionsForm.isDontTagRelease()));
PropertiesComponent.getInstance(project).setValue(GITFLOW_DONT_TAG_HOTFIX, Boolean.toString(gitflowOptionsForm.isDontTagHotfix()));
PropertiesComponent.getInstance(project).setValue(GITFLOW_USE_CUSTOM_TAG_COMMIT_MESSAGE, Boolean.toString(gitflowOptionsForm.isUseCustomTagCommitMessage()));
PropertiesComponent.getInstance(project).setValue(GITFLOW_CUSTOM_TAG_COMMIT_MESSAGE, gitflowOptionsForm.getCustomTagCommitMessage());

PropertiesComponent.getInstance(project).setValue(GITFLOW_PUSH_ON_FINISH_HOTFIX, Boolean.toString(gitflowOptionsForm.isPushOnFinishHotfix()));
PropertiesComponent.getInstance(project).setValue(GITFLOW_DONT_TAG_HOTFIX, Boolean.toString(gitflowOptionsForm.isDontTagHotfix()));
PropertiesComponent.getInstance(project).setValue(GITFLOW_USE_CUSTOM_HOTFIX_TAG_COMMIT_MESSAGE, Boolean.toString(gitflowOptionsForm.isUseCustomHotfixComitMessage()));
PropertiesComponent.getInstance(project).setValue(GITFLOW_CUSTOM_HOTFIX_TAG_COMMIT_MESSAGE, gitflowOptionsForm.getCustomHotfixCommitMessage());
}

@Override
public void reset() {
gitflowOptionsForm.setFeatureKeepRemote(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_FEATURE_KEEP_REMOTE, false));

gitflowOptionsForm.setPushOnFinishRelease(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_PUSH_ON_FINISH_RELEASE, false));
gitflowOptionsForm.setPushOnFinishHotfix(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_PUSH_ON_FINISH_HOTFIX, false));
gitflowOptionsForm.setDontTagRelease(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_DONT_TAG_RELEASE, false));
gitflowOptionsForm.setDontTagHotfix(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_DONT_TAG_HOTFIX, false));
gitflowOptionsForm.setUseCustomTagCommitMessage(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_USE_CUSTOM_TAG_COMMIT_MESSAGE, false));
gitflowOptionsForm.setCustomTagCommitMessage(PropertiesComponent.getInstance(project).getValue(GITFLOW_CUSTOM_TAG_COMMIT_MESSAGE,DEFAULT_TAG_COMMIT_MESSAGE));

gitflowOptionsForm.setPushOnFinishHotfix(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_PUSH_ON_FINISH_HOTFIX, false));
gitflowOptionsForm.setDontTagHotfix(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_DONT_TAG_HOTFIX, false));
gitflowOptionsForm.setUseCustomHotfixCommitMessage(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_USE_CUSTOM_HOTFIX_TAG_COMMIT_MESSAGE, false));
gitflowOptionsForm.setCustomHotfixCommitMessage(PropertiesComponent.getInstance(project).getValue(GITFLOW_CUSTOM_HOTFIX_TAG_COMMIT_MESSAGE,DEFAULT_TAG_HOTFIX_COMMIT_MESSAGE));
}
Expand Down
5 changes: 5 additions & 0 deletions src/gitflow/GitflowImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ public GitCommandResult finishFeature(@NotNull GitRepository repository,

h.addParameters("feature");
h.addParameters("finish");

if (GitflowConfigurable.featureKeepRemote(repository.getProject())) {
h.addParameters("--keepremote");
}

h.addParameters(featureName);

for (GitLineHandlerListener listener : listeners) {
Expand Down
39 changes: 34 additions & 5 deletions src/gitflow/ui/GitflowOptionsForm.form
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="gitflow.ui.GitflowOptionsForm">
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="4" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="contentPane" layout-manager="GridLayoutManager" row-count="5" column-count="1" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<xy x="20" y="20" width="500" height="400"/>
<xy x="20" y="20" width="500" height="497"/>
</constraints>
<properties/>
<border type="none"/>
<children>
<vspacer id="1a5be">
<constraints>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="4" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<grid id="6abe9" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none" title="Release"/>
Expand Down Expand Up @@ -64,7 +64,7 @@
<grid id="35b8b" layout-manager="GridLayoutManager" row-count="4" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="2" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
<grid row="3" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none" title="Hotfix"/>
Expand Down Expand Up @@ -109,6 +109,35 @@
</component>
</children>
</grid>
<grid id="ee6f8" layout-manager="GridLayoutManager" row-count="2" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="0" left="0" bottom="0" right="0"/>
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="3" hsize-policy="3" anchor="0" fill="3" indent="0" use-parent-layout="false"/>
</constraints>
<properties/>
<border type="none" title="Feature"/>
<children>
<component id="88b52" class="javax.swing.JCheckBox" binding="featureKeepRemote">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<selected value="false"/>
<text value="Keep remote (--keepremote)"/>
</properties>
</component>
<hspacer id="7cd8c">
<constraints>
<grid row="0" column="1" row-span="1" col-span="1" vsize-policy="1" hsize-policy="6" anchor="0" fill="1" indent="0" use-parent-layout="false"/>
</constraints>
</hspacer>
<vspacer id="1e7f4">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
</children>
</grid>
</children>
</grid>
</form>
46 changes: 28 additions & 18 deletions src/gitflow/ui/GitflowOptionsForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,18 @@
* @author Opher Vishnia ([email protected])
*/
public class GitflowOptionsForm implements ItemListener {
private JCheckBox pushOnFinishRelease;
private JPanel contentPane;
private JCheckBox pushOnFinishHotfix;
private JCheckBox featureKeepRemote;

private JCheckBox pushOnFinishRelease;
private JCheckBox dontTagRelease;
private JCheckBox useCustomTagCommitMessage;
private JTextField customTagCommitMessage;
private JTextField customHotfixCommitMessage;
private JCheckBox useCustomHotfixCommitMessage;

private JCheckBox pushOnFinishHotfix;
private JCheckBox dontTagHotfix;
private JCheckBox useCustomHotfixCommitMessage;
private JTextField customHotfixCommitMessage;

public JPanel getContentPane() {
dontTagRelease.addItemListener(this);
Expand Down Expand Up @@ -83,6 +86,8 @@ else if (source == dontTagHotfix) {

}

// getters/setters

public boolean isPushOnFinishRelease()
{
return pushOnFinishRelease.isSelected();
Expand All @@ -93,23 +98,11 @@ public void setPushOnFinishRelease(boolean selected)
pushOnFinishRelease.setSelected(selected);
}

public boolean isPushOnFinishHotfix() {
return pushOnFinishHotfix.isSelected();
}

public void setPushOnFinishHotfix(boolean selected) {
pushOnFinishHotfix.setSelected(selected);
}

public boolean isDontTagRelease() { return dontTagRelease.isSelected(); }

public boolean isDontTagHotfix() { return dontTagHotfix.isSelected(); }

public void setDontTagRelease(boolean selected) {
dontTagRelease.setSelected(selected);
}
public boolean isFeatureKeepRemote() { return featureKeepRemote.isSelected(); }

public void setDontTagHotfix(boolean selected) { dontTagHotfix.setSelected(selected); }
public void setFeatureKeepRemote(boolean selected) { featureKeepRemote.setSelected(selected); }


/* custom finish release tag commit message */
Expand All @@ -130,6 +123,23 @@ public void setCustomTagCommitMessage(String message) {
customTagCommitMessage.setText(message);
}



public boolean isPushOnFinishHotfix() { return pushOnFinishHotfix.isSelected(); }

public void setPushOnFinishHotfix(boolean selected) { pushOnFinishHotfix.setSelected(selected); }


public boolean isDontTagHotfix() { return dontTagHotfix.isSelected(); }

public void setDontTagRelease(boolean selected) {
dontTagRelease.setSelected(selected);
}

public void setDontTagHotfix(boolean selected) { dontTagHotfix.setSelected(selected); }



/* custom finish hotfix commit message */

public boolean isUseCustomHotfixComitMessage(){
Expand Down

0 comments on commit 037d927

Please sign in to comment.