Skip to content

Commit

Permalink
Fixed issue #39, added the option to not tag hotfix (-n)
Browse files Browse the repository at this point in the history
  • Loading branch information
OpherV committed Jun 27, 2014
1 parent a23ba80 commit 0162daf
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 9 deletions.
8 changes: 8 additions & 0 deletions src/gitflow/GitflowConfigurable.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class GitflowConfigurable implements Configurable {
public static final String GITFLOW_DONT_TAG_RELEASE = "Gitflow.dontTagRelease";
public static final String GITFLOW_USE_CUSTOM_TAG_COMMIT_MESSAGE = "Gitflow.useCustomTagCommitMessage";
public static final String GITFLOW_CUSTOM_TAG_COMMIT_MESSAGE = "Gitflow.customTagCommitMessage";
public static final String GITFLOW_DONT_TAG_HOTFIX = "Gitflow.dontTagHotfix";
public static final String GITFLOW_USE_CUSTOM_HOTFIX_TAG_COMMIT_MESSAGE = "Gitflow.useCustomHotfixTagCommitMessage";
public static final String GITFLOW_CUSTOM_HOTFIX_TAG_COMMIT_MESSAGE = "Gitflow.customHotfixTagCommitMessage";

Expand Down Expand Up @@ -47,6 +48,10 @@ 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 Down Expand Up @@ -101,6 +106,7 @@ 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() ||
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_USE_CUSTOM_HOTFIX_TAG_COMMIT_MESSAGE, false) != gitflowOptionsForm.isUseCustomHotfixComitMessage() ||
Expand All @@ -113,6 +119,7 @@ public void apply() throws ConfigurationException {
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());

Expand All @@ -125,6 +132,7 @@ public void reset() {
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));

Expand Down
12 changes: 10 additions & 2 deletions src/gitflow/GitflowImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,8 +314,16 @@ public GitCommandResult finishHotfix(@NotNull GitRepository repository,
if (GitflowConfigurable.pushOnHotfixFinish(repository.getProject())) {
h.addParameters("-p");
}
h.addParameters("-m");
h.addParameters(tagMessage);


if (GitflowConfigurable.dontTagHotfix(repository.getProject())) {
h.addParameters("-n");
}
else{
h.addParameters("-m");
h.addParameters(tagMessage);
}

h.addParameters(hotfixName);

for (GitLineHandlerListener listener : listeners) {
Expand Down
10 changes: 9 additions & 1 deletion src/gitflow/actions/FinishHotfixAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,18 @@ public void actionPerformed(AnActionEvent e) {
//TODO HOTFIX NAME
final String hotfixName = GitflowConfigUtil.getHotfixNameFromBranch(myProject, currentBranchName);

final String tagMessage;

String defaultTagMessage= GitflowConfigurable.getCustomHotfixTagCommitMessage(myProject);
defaultTagMessage=defaultTagMessage.replace("%name%", hotfixName);

final String tagMessage = Messages.showInputDialog(myProject, "Enter the tag message:", "Finish Hotfix", Messages.getQuestionIcon(), defaultTagMessage, null);
if (GitflowConfigurable.dontTagHotfix(myProject)) {
tagMessage="";
}
else {
tagMessage = Messages.showInputDialog(myProject, "Enter the tag message:", "Finish Hotfix", Messages.getQuestionIcon(), defaultTagMessage, null);
}

final GitflowErrorsListener errorLineHandler = new GitflowErrorsListener(myProject);

if (tagMessage!=null){
Expand Down
15 changes: 12 additions & 3 deletions src/gitflow/ui/GitflowOptionsForm.form
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
</component>
</children>
</grid>
<grid id="35b8b" layout-manager="GridLayoutManager" row-count="3" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<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"/>
Expand All @@ -71,7 +71,7 @@
<children>
<component id="a8413" class="javax.swing.JTextField" binding="customHotfixCommitMessage">
<constraints>
<grid row="1" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<grid row="2" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="6" anchor="8" fill="1" indent="0" use-parent-layout="false">
<preferred-size width="150" height="-1"/>
</grid>
</constraints>
Expand All @@ -84,7 +84,7 @@
</component>
<component id="4c1d4" class="javax.swing.JCheckBox" binding="useCustomHotfixCommitMessage">
<constraints>
<grid row="1" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="3" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
<grid row="2" 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>
<text value="Use custom hotfix commit message"/>
Expand All @@ -98,6 +98,15 @@
<text value="Push on finish hotfix (-p)"/>
</properties>
</component>
<component id="88094" class="javax.swing.JCheckBox" binding="dontTagHotfix">
<constraints>
<grid row="1" 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="Don't tag hotfix (-n)"/>
</properties>
</component>
</children>
</grid>
</children>
Expand Down
23 changes: 20 additions & 3 deletions src/gitflow/ui/GitflowOptionsForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ public class GitflowOptionsForm implements ItemListener {
private JTextField customTagCommitMessage;
private JTextField customHotfixCommitMessage;
private JCheckBox useCustomHotfixCommitMessage;
private JCheckBox dontTagHotfix;

public JPanel getContentPane() {
dontTagRelease.addItemListener(this);
dontTagHotfix.addItemListener(this);
useCustomTagCommitMessage.addItemListener(this);
useCustomHotfixCommitMessage.addItemListener(this);
return contentPane;
Expand Down Expand Up @@ -64,6 +66,19 @@ else if (source == dontTagRelease) {
customHotfixCommitMessage.setEditable(false);
}
}
else if (source == dontTagHotfix) {
if (e.getStateChange() == ItemEvent.SELECTED) {
useCustomHotfixCommitMessage.setEnabled(false);
customHotfixCommitMessage.setEnabled(false);
}
else{
useCustomHotfixCommitMessage.setEnabled(true);
if( useCustomHotfixCommitMessage.isSelected()){
customHotfixCommitMessage.setEnabled(true);
customHotfixCommitMessage.setEditable(true);
}
}
}


}
Expand All @@ -86,14 +101,16 @@ public void setPushOnFinishHotfix(boolean selected) {
pushOnFinishHotfix.setSelected(selected);
}

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

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

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

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


/* custom finish release tag commit message */

Expand Down

0 comments on commit 0162daf

Please sign in to comment.