Skip to content

Commit

Permalink
Finished #22, #23
Browse files Browse the repository at this point in the history
  • Loading branch information
OpherV committed Feb 1, 2014
1 parent b6f9ad0 commit 5ef8c77
Show file tree
Hide file tree
Showing 4 changed files with 79 additions and 17 deletions.
26 changes: 23 additions & 3 deletions src/gitflow/GitflowActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -506,11 +506,31 @@ public void actionPerformed(AnActionEvent e) {

final String releaseName = GitflowConfigUtil.getReleaseNameFromBranch(myProject, currentBranchName);
final gitFlowErrorsListener errorLineHandler = new gitFlowErrorsListener();
String defaultTagMessage="Tagging version "+releaseName;
String defaultTagMessage=GitflowConfigurable.getCustomTagCommitMessage(myProject);
defaultTagMessage=defaultTagMessage.replace("%name%", releaseName);

final String tagMessage = Messages.showInputDialog(myProject, "Enter the tag message:", "Finish Release", Messages.getQuestionIcon(), defaultTagMessage, null);
String tagMessageDraft;
final String tagMessage;

if (tagMessage!=null){
boolean cancelAction=false;

if (GitflowConfigurable.dontTagRelease(myProject)) {
tagMessage="";
}
else{
tagMessageDraft=Messages.showInputDialog(myProject, "Enter the tag message:", "Finish Release", Messages.getQuestionIcon(), defaultTagMessage, null);
if (tagMessageDraft==null){
cancelAction=true;
tagMessage="";
}
else{

tagMessage=tagMessageDraft;
}
}


if (!cancelAction){

new Task.Backgroundable(myProject,"Finishing release "+releaseName,false){
@Override
Expand Down
31 changes: 29 additions & 2 deletions src/gitflow/GitflowConfigurable.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,32 @@ public GitflowConfigurable(Project project)
this.project = project;
}

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 useCustomTagCommitMessage(Project project) {
return PropertiesComponent.getInstance(project).getBoolean(GitflowConfigurable.GITFLOW_USE_CUSTOM_TAG_COMMIT_MESSAGE, false);
}

public static String getCustomTagCommitMessage(Project project) {
if (useCustomTagCommitMessage(project)){
return PropertiesComponent.getInstance(project).getValue(GitflowConfigurable.GITFLOW_CUSTOM_TAG_COMMIT_MESSAGE);
}
else{
return GitflowConfigurable.DEFAULT_TAG_COMMIT_MESSAGE;
}
}


@Override
public String getDisplayName() {
return "Gitflow";
Expand Down Expand Up @@ -65,7 +91,8 @@ 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_CUSTOM_TAG_COMMIT_MESSAGE, Boolean.toString(gitflowOptionsForm.isDontTagRelease()));
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());
}

@Override
Expand All @@ -74,7 +101,7 @@ public void reset() {
gitflowOptionsForm.setPushOnFinishHotfix(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_PUSH_ON_FINISH_HOTFIX, false));
gitflowOptionsForm.setDontTagRelease(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_DONT_TAG_RELEASE, false));
gitflowOptionsForm.setUseCustomTagCommitMessage(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_USE_CUSTOM_TAG_COMMIT_MESSAGE, false));
gitflowOptionsForm.setCustomTagCommitMessage(PropertiesComponent.getInstance(project).getValue(GITFLOW_USE_CUSTOM_TAG_COMMIT_MESSAGE, DEFAULT_TAG_COMMIT_MESSAGE));
gitflowOptionsForm.setCustomTagCommitMessage(PropertiesComponent.getInstance(project).getValue(GITFLOW_CUSTOM_TAG_COMMIT_MESSAGE));
}

@Override
Expand Down
23 changes: 11 additions & 12 deletions src/gitflow/GitflowImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -228,22 +228,25 @@ public GitCommandResult finishRelease(@NotNull GitRepository repository,

h.addParameters("release");
h.addParameters("finish");
if(pushOnReleaseFinish(repository.getProject())) {
if(GitflowConfigurable.pushOnReleaseFinish(repository.getProject())) {
h.addParameters("-p");
}
h.addParameters("-m");
h.addParameters(StringEscapeUtils.escapeJava(tagMessage));
h.addParameters(releaseName);

if (GitflowConfigurable.dontTagRelease(repository.getProject())) {
h.addParameters("-n");
}
else{
h.addParameters("-m");
h.addParameters(StringEscapeUtils.escapeJava(tagMessage));
h.addParameters(releaseName);
}

for (GitLineHandlerListener listener : listeners) {
h.addLineListener(listener);
}
return run(h);
}

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

public GitCommandResult publishRelease(@NotNull GitRepository repository,
@NotNull String releaseName,
Expand Down Expand Up @@ -309,7 +312,7 @@ public GitCommandResult finishHotfix(@NotNull GitRepository repository,

h.addParameters("hotfix");
h.addParameters("finish");
if (pushOnHotfixFinish(repository.getProject())) {
if (GitflowConfigurable.pushOnHotfixFinish(repository.getProject())) {
h.addParameters("-p");
}
h.addParameters("-m");
Expand All @@ -322,10 +325,6 @@ public GitCommandResult finishHotfix(@NotNull GitRepository repository,
return run(h);
}

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

public GitCommandResult publishHotfix(@NotNull GitRepository repository,
@NotNull String hotfixName,
@Nullable GitLineHandlerListener... listeners) {
Expand Down
16 changes: 16 additions & 0 deletions src/gitflow/ui/GitflowOptionsForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public class GitflowOptionsForm implements ItemListener {
private JTextField customTagCommitMessage;

public JPanel getContentPane() {
dontTagRelease.addItemListener(this);
useCustomTagCommitMessage.addItemListener(this);
return contentPane;
}
Expand All @@ -30,11 +31,26 @@ public void itemStateChanged(ItemEvent e) {
if (source == useCustomTagCommitMessage) {
if (e.getStateChange() == ItemEvent.SELECTED) {
customTagCommitMessage.setEditable(true);
customTagCommitMessage.setEnabled(true);
}
else{
customTagCommitMessage.setEditable(false);
}
}
else if (source == dontTagRelease) {
if (e.getStateChange() == ItemEvent.SELECTED) {
useCustomTagCommitMessage.setEnabled(false);
customTagCommitMessage.setEnabled(false);
}
else{
useCustomTagCommitMessage.setEnabled(true);
if( useCustomTagCommitMessage.isSelected()){
customTagCommitMessage.setEnabled(true);
}
}
}



}

Expand Down

0 comments on commit 5ef8c77

Please sign in to comment.