Skip to content

Commit

Permalink
Merge branch 'release/0.6.6'
Browse files Browse the repository at this point in the history
  • Loading branch information
OpherV committed Sep 21, 2018
2 parents 79aa567 + fa8619c commit 8e5f6d4
Show file tree
Hide file tree
Showing 9 changed files with 47 additions and 39 deletions.
4 changes: 2 additions & 2 deletions META-INF/plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@
<name>Git Flow Integration</name>
<id>Gitflow</id>
<description>Git Flow Integration</description>
<version>0.6.5.1</version>
<version>0.6.6</version>
<category>VCS Integration</category>
<vendor url="http://www.opherv.com">Opher Vishnia</vendor>

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

<idea-version since-build="181.0" until-build="181.*"/>
<idea-version since-build="182.0" until-build="182.*"/>

<actions>
<action id="Gitflow.OpenGitflowPopup" class="gitflow.actions.OpenGitflowPopup"
Expand Down
18 changes: 18 additions & 0 deletions src/gitflow/DefaultOptions.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package gitflow;

import java.util.HashMap;
import java.util.Map;

public class DefaultOptions {
private static final Map<String, String> options;
static
{
options = new HashMap<String, String>();
options.put("RELEASE_customTagCommitMessage", "Tagging version %name%");
options.put("HOTFIX_customHotfixCommitMessage", "Tagging hotfix %name%");
}

public static String getOption(String optionId){
return options.get(optionId);
}
}
9 changes: 8 additions & 1 deletion src/gitflow/GitflowConfigurable.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

import javax.swing.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

/**
Expand All @@ -21,12 +22,14 @@ public class GitflowConfigurable implements Configurable {
GitflowOptionsForm gitflowOptionsForm;
PropertiesComponent propertiesComponent;
Map<Enum<GitflowOptionsFactory.TYPE>, ArrayList<Map<String,String>>> gitflowOptions;
Map<String, String> optionDefaults;

static GitflowConfigurable instance;

public GitflowConfigurable(Project project) {
gitflowOptions = GitflowOptionsFactory.getOptions();
propertiesComponent = PropertiesComponent.getInstance(project);
optionDefaults = new HashMap<String, String>();
this.project = project;
instance = this;
}
Expand Down Expand Up @@ -58,7 +61,11 @@ public static boolean isOptionActive(Project project, String optionId){
}

public static String getOptionTextString (Project project, String optionId){
return PropertiesComponent.getInstance(project).getValue(optionId+"_text");
String retValue = PropertiesComponent.getInstance(project).getValue(optionId+"_text");
if (retValue == null){
retValue = DefaultOptions.getOption(optionId);
}
return retValue;
}

@Override
Expand Down
4 changes: 2 additions & 2 deletions src/gitflow/GitflowOptionsFactory.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ private GitflowOptionsFactory(){
addOption(TYPE.RELEASE, "Keep branch after performing finish", "keepBranch" , "-k");
// addOption(TYPE.RELEASE, "Squash release during merge", "squash" , "-S");
addOption(TYPE.RELEASE, "Don't tag release", "dontTag" , "-n");
addOption(TYPE.RELEASE, "Use custom tag commit message", "customTagCommitMessage" , null, "Tagging version %name%" ,"Use %name% for the branch name");
addOption(TYPE.RELEASE, "Use custom tag commit message", "customTagCommitMessage" , null, DefaultOptions.getOption("RELEASE_customTagCommitMessage") ,"Use %name% for the branch name");

addBranchType(TYPE.HOTFIX);
addOption(TYPE.HOTFIX, "Fetch from Origin", "fetchFromOrigin" , "-F");
addOption(TYPE.HOTFIX, "Push on finish Hotfix", "pushOnFinish" , "-p");
addOption(TYPE.HOTFIX, "Don't tag Hotfix", "dontTag" , "-n");
addOption(TYPE.HOTFIX, "Use custom hotfix commit message", "customHotfixCommitMessage" , null, "Tagging hotfix %name%" ,"Use %name% for the branch name");
addOption(TYPE.HOTFIX, "Use custom hotfix commit message", "customHotfixCommitMessage" , null, DefaultOptions.getOption("HOTFIX_customHotfixCommitMessage") ,"Use %name% for the branch name");
}

private void addBranchType(Enum<TYPE> branchType){
Expand Down
16 changes: 3 additions & 13 deletions src/gitflow/actions/FinishHotfixAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,26 +29,16 @@ public void actionPerformed(AnActionEvent e) {
String currentBranchName = GitBranchUtil.getBranchNameOrRev(myRepo);


if (currentBranchName.isEmpty()==false){
if (currentBranchName.isEmpty() == false){

//TODO HOTFIX NAME
final String hotfixName = GitflowConfigUtil.getHotfixNameFromBranch(myProject, myRepo, currentBranchName);

final String tagMessage;
String tagMessageTemplate;

String defaultTagMessage = "Tagging hotfix %name%";
String customTagMessage = GitflowConfigurable.getOptionTextString(myProject, "HOTFIX_customHotfixCommitMessage");

if (customTagMessage != null) {
tagMessageTemplate = customTagMessage.replace("%name%", hotfixName);
}
else{
tagMessageTemplate = defaultTagMessage.replace("%name%", hotfixName);
}
String tagMessageTemplate = GitflowConfigurable.getOptionTextString(myProject, "HOTFIX_customHotfixCommitMessage").replace("%name%", hotfixName);

if (GitflowConfigurable.isOptionActive(myProject, "HOTFIX_dontTag")) {
tagMessage="";
tagMessage = "";
}
else {
tagMessage = Messages.showInputDialog(myProject, "Enter the tag message:", "Finish Hotfix", Messages.getQuestionIcon(), tagMessageTemplate, null);
Expand Down
15 changes: 2 additions & 13 deletions src/gitflow/actions/FinishReleaseAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -47,21 +47,10 @@ public void actionPerformed(AnActionEvent e) {
releaseName = customReleaseName!=null ? customReleaseName:GitflowConfigUtil.getReleaseNameFromBranch(myProject, myRepo, currentBranchName);

final GitflowErrorsListener errorLineHandler = new GitflowErrorsListener(myProject);

String tagMessageTemplate;

String defaultTagMessage = "Tagging version %name%";
String customTagMessage = GitflowConfigurable.getOptionTextString(myProject, "RELEASE_customTagCommitMessage");
if (customTagMessage != null) {
tagMessageTemplate = customTagMessage.replace("%name%", releaseName);
}
else{
tagMessageTemplate = defaultTagMessage.replace("%name%", releaseName);
}


String tagMessageTemplate = GitflowConfigurable.getOptionTextString(myProject, "RELEASE_customTagCommitMessage").replace("%name%", releaseName);
String tagMessageDraft;


boolean cancelAction=false;

if (GitflowConfigurable.isOptionActive(myProject, "RELEASE_dontTag")) {
Expand Down
5 changes: 0 additions & 5 deletions src/gitflow/actions/GitflowLineHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.intellij.openapi.project.Project;
import com.intellij.openapi.util.Key;
import git4idea.commands.GitLineHandlerListener;
import org.apache.commons.lang.StringUtils;

import java.util.ArrayList;

Expand All @@ -24,8 +23,4 @@ public void processTerminated(int exitCode) {}

@Override
public void startFailed(Throwable exception) {}

public String getErrors(){
return StringUtils.join(myErrors, ",");
}
}
11 changes: 11 additions & 0 deletions src/gitflow/ui/GitflowBranchChooseDialog.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.intellij.openapi.project.Project;
import com.intellij.openapi.ui.DialogWrapper;
import com.intellij.openapi.ui.ValidationInfo;
import org.jetbrains.annotations.Nullable;

import javax.swing.*;
Expand Down Expand Up @@ -29,6 +30,16 @@ public GitflowBranchChooseDialog(Project project, List<String> branchNames) {
init();
}

@Nullable
@Override
protected ValidationInfo doValidate() {
if (branchList.getSelectedValue() == null){
return new ValidationInfo("No branch selected!");
} else {
return null;
}
}

@Nullable
@Override
protected JComponent createCenterPanel() {
Expand Down
4 changes: 1 addition & 3 deletions src/gitflow/ui/GitflowCloseTaskPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ public class GitflowCloseTaskPanel extends TaskDialogPanel {
String branchName = myVcsTaskHandler != null
? myVcsTaskHandler.cleanUpBranchName(myTaskManager.constructDefaultBranchName(task))
: myTaskManager.suggestBranchName(task);

//TODO same code exists in FinishHotfixAction, make DRYer


if (GitflowConfigurable.isOptionActive(project, "HOTFIX_dontTag")) {
tagMessage="";
tagMessageTextField.setEnabled(false);
Expand Down

0 comments on commit 8e5f6d4

Please sign in to comment.