Skip to content

Commit

Permalink
Merge branch 'release/0.6.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
OpherV committed Apr 4, 2018
2 parents a211795 + 7b570c5 commit 388618e
Show file tree
Hide file tree
Showing 10 changed files with 365 additions and 559 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.4</version>
<version>0.6.5</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="162.0" until-build="181.*"/>
<idea-version since-build="181.0" until-build="181.*"/>

<actions>
<action id="Gitflow.OpenGitflowPopup" class="gitflow.actions.OpenGitflowPopup"
Expand Down
223 changes: 81 additions & 142 deletions src/gitflow/GitflowConfigurable.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,114 +8,31 @@
import org.jetbrains.annotations.Nullable;

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

/**
* @author Andreas Vogler ([email protected])
* @author Opher Vishnia ([email protected])
*/
public class GitflowConfigurable implements Configurable {

public static final String GITFLOW_FEATURE_FETCH_ORIGIN = "Gitflow.featureFetchOrigin";
public static final String GITFLOW_FEATURE_KEEP_REMOTE = "Gitflow.featureKeepRemote";
public static final String GITFLOW_FEATURE_KEEP_LOCAL = "Gitflow.featureKeepLocal";
public static final String GITFLOW_FEATURE_NO_FF = "Gitflow.featureNoFastForward";

public static final String GITFLOW_RELEASE_FETCH_ORIGIN = "Gitflow.releaseFetchOrigin";
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";
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_HOTFIX_FETCH_ORIGIN = "Gitflow.hotfixFetchOrigin";
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";

public static final String DEFAULT_TAG_COMMIT_MESSAGE ="Tagging version %name%";
public static final String DEFAULT_TAG_HOTFIX_COMMIT_MESSAGE ="Tagging version %name%";

Project project;
GitflowOptionsForm gitflowOptionsForm;
PropertiesComponent propertiesComponent;
Map<Enum<GitflowOptionsFactory.TYPE>, ArrayList<Map<String,String>>> gitflowOptions;

static GitflowConfigurable instance;

public GitflowConfigurable(Project project) {
gitflowOptions = GitflowOptionsFactory.getOptions();
propertiesComponent = PropertiesComponent.getInstance(project);
this.project = project;
instance = this;
}

/* feature */

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

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

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

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

/* release */

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

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

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

/* finish release custom commit message */

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;
}
}

/*hotfix*/

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

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);
}

public static String getCustomHotfixTagCommitMessage(Project project) {
if (useCustomHotfixTagCommitMessage(project)){
return PropertiesComponent.getInstance(project).getValue(GitflowConfigurable.GITFLOW_CUSTOM_HOTFIX_TAG_COMMIT_MESSAGE);
}
else{
return GitflowConfigurable.DEFAULT_TAG_HOTFIX_COMMIT_MESSAGE;
}
static public GitflowConfigurable getInstance(){
return instance;
}

@Override
Expand All @@ -136,64 +53,86 @@ public JComponent createComponent() {
return gitflowOptionsForm.getContentPane();
}

public boolean isOptionActive(String optionId){
return propertiesComponent.getBoolean(optionId+"_active");
}

public String getOptionTextString (String optionId){
return propertiesComponent.getValue(optionId+"_text");
}

@Override
public boolean isModified() {
return PropertiesComponent.getInstance(project).getBoolean(GITFLOW_FEATURE_FETCH_ORIGIN, false) != gitflowOptionsForm.isFeatureFetchOrigin() ||
PropertiesComponent.getInstance(project).getBoolean(GITFLOW_FEATURE_KEEP_REMOTE, false) != gitflowOptionsForm.isFeatureKeepRemote() ||
PropertiesComponent.getInstance(project).getBoolean(GITFLOW_FEATURE_KEEP_LOCAL, false) != gitflowOptionsForm.isFeatureKeepLocal() ||
PropertiesComponent.getInstance(project).getBoolean(GITFLOW_FEATURE_NO_FF, false) != gitflowOptionsForm.isFeatureNoFastForward() ||

PropertiesComponent.getInstance(project).getBoolean(GITFLOW_RELEASE_FETCH_ORIGIN, false) != gitflowOptionsForm.isReleaseFetchOrigin() ||
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_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_HOTFIX_FETCH_ORIGIN, false) != gitflowOptionsForm.isHotfixFetchOrigin() ||
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;
// iterate over branch types (feature/release/hotfix)
for (GitflowOptionsFactory.TYPE type: GitflowOptionsFactory.TYPE.values()) {
for (Map<String, String> optionMap : gitflowOptions.get(type)) {
String optionId = GitflowOptionsFactory.getOptionId(type, optionMap.get("key"));

boolean isOptionActiveInForm = gitflowOptionsForm.isOptionActive(optionId);
boolean savedOptionIsActive = propertiesComponent.getBoolean(optionId+"_active");

if (isOptionActiveInForm != savedOptionIsActive) return true;

// option has text value
if (optionMap.get("inputText") != null){
String textInForm = gitflowOptionsForm.getOptionText(optionId);
String savedOptionText = propertiesComponent.getValue(optionId+"text");
if (textInForm.equals(savedOptionText) == false){
return true;
}
}

}
}

return false;
}

@Override
public void apply() throws ConfigurationException {
PropertiesComponent.getInstance(project).setValue(GITFLOW_FEATURE_FETCH_ORIGIN, Boolean.toString(gitflowOptionsForm.isFeatureFetchOrigin()));
PropertiesComponent.getInstance(project).setValue(GITFLOW_FEATURE_KEEP_REMOTE, Boolean.toString(gitflowOptionsForm.isFeatureKeepRemote()));
PropertiesComponent.getInstance(project).setValue(GITFLOW_FEATURE_KEEP_LOCAL, Boolean.toString(gitflowOptionsForm.isFeatureKeepLocal()));
PropertiesComponent.getInstance(project).setValue(GITFLOW_FEATURE_NO_FF, Boolean.toString(gitflowOptionsForm.isFeatureNoFastForward()));

PropertiesComponent.getInstance(project).setValue(GITFLOW_RELEASE_FETCH_ORIGIN, Boolean.toString(gitflowOptionsForm.isReleaseFetchOrigin()));
PropertiesComponent.getInstance(project).setValue(GITFLOW_PUSH_ON_FINISH_RELEASE, Boolean.toString(gitflowOptionsForm.isPushOnFinishRelease()));
PropertiesComponent.getInstance(project).setValue(GITFLOW_DONT_TAG_RELEASE, 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());

PropertiesComponent.getInstance(project).setValue(GITFLOW_HOTFIX_FETCH_ORIGIN, Boolean.toString(gitflowOptionsForm.isHotfixFetchOrigin()));
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());
// iterate over branch types (feature/release/hotfix)
for (GitflowOptionsFactory.TYPE type: GitflowOptionsFactory.TYPE.values()) {
for (Map<String, String> optionMap : gitflowOptions.get(type)) {
String optionId = GitflowOptionsFactory.getOptionId(type, optionMap.get("key"));

// set isActive value
propertiesComponent.setValue(optionId+"_active", gitflowOptionsForm.isOptionActive(optionId));

// set text value, if relevant
if (optionMap.get("inputText") != null){
propertiesComponent.setValue(optionId+"_text", gitflowOptionsForm.getOptionText(optionId));
}

}
}

}

@Override
public void reset() {
gitflowOptionsForm.setFeatureFetchOrigin(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_FEATURE_FETCH_ORIGIN, false));
gitflowOptionsForm.setFeatureKeepRemote(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_FEATURE_KEEP_REMOTE, false));
gitflowOptionsForm.setFeatureKeepLocal(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_FEATURE_KEEP_LOCAL, false));
gitflowOptionsForm.setFeatureNoFastForward(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_FEATURE_NO_FF, false));

gitflowOptionsForm.setReleaseFetchOrigin(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_RELEASE_FETCH_ORIGIN, false));
gitflowOptionsForm.setPushOnFinishRelease(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_PUSH_ON_FINISH_RELEASE, 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_CUSTOM_TAG_COMMIT_MESSAGE,DEFAULT_TAG_COMMIT_MESSAGE));

gitflowOptionsForm.setHotfixFetchOrigin(PropertiesComponent.getInstance(project).getBoolean(GITFLOW_HOTFIX_FETCH_ORIGIN, false));
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));
// iterate over branch types (feature/release/hotfix)
for (GitflowOptionsFactory.TYPE type: GitflowOptionsFactory.TYPE.values()) {
for (Map<String, String> optionMap : gitflowOptions.get(type)) {
String optionId = GitflowOptionsFactory.getOptionId(type, optionMap.get("key"));
boolean savedOptionIsActive = propertiesComponent.getBoolean(optionId+"_active");
gitflowOptionsForm.setOptionActive(optionId, savedOptionIsActive);

// option has text value
if (optionMap.get("inputText") != null){
String textInForm = gitflowOptionsForm.getOptionText(optionId);
String savedOptionText = propertiesComponent.getValue(optionId+"text");
if (savedOptionText == null){
gitflowOptionsForm.setOptionText(optionId, optionMap.get("inputText"));
}
else{
gitflowOptionsForm.setOptionText(optionId, savedOptionText);
}

}

}
}
gitflowOptionsForm.updateFormDisabledStatus();
}

@Override
Expand Down
Loading

0 comments on commit 388618e

Please sign in to comment.