diff --git a/commit_template.jar b/commit_template.jar
index 6ce1c33..ec90d15 100644
Binary files a/commit_template.jar and b/commit_template.jar differ
diff --git a/resources/META-INF/plugin.xml b/resources/META-INF/plugin.xml
index c6c0082..7c8712a 100644
--- a/resources/META-INF/plugin.xml
+++ b/resources/META-INF/plugin.xml
@@ -9,6 +9,11 @@
]]>
1.0.3-mkempster-20171129
+
+ - Option to append template text to an existing commit message instead of completely overwriting.
+ - Use case: Add crucible smart-commit macros to the default message.
+
1.0.3
- Added the ability to set commentChar when loading template from file.
diff --git a/src/commitmessagetemplate/CommitMessageTemplateAction.java b/src/commitmessagetemplate/CommitMessageTemplateAction.java
index 6f7f93e..b32aeb4 100644
--- a/src/commitmessagetemplate/CommitMessageTemplateAction.java
+++ b/src/commitmessagetemplate/CommitMessageTemplateAction.java
@@ -28,6 +28,7 @@
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.project.DumbAware;
+import com.intellij.openapi.vcs.CheckinProjectPanel;
import com.intellij.openapi.vcs.CommitMessageI;
import com.intellij.openapi.vcs.VcsDataKeys;
import com.intellij.openapi.vcs.ui.Refreshable;
@@ -39,7 +40,7 @@
public class CommitMessageTemplateAction extends AnAction implements DumbAware {
public void actionPerformed(AnActionEvent e) {
- final CommitMessageI checkinPanel = getCheckinPanel(e);
+ final CheckinProjectPanel checkinPanel = getCheckinPanel(e);
if (checkinPanel == null) {
return;
}
@@ -50,25 +51,30 @@ public void actionPerformed(AnActionEvent e) {
if (config != null) {
String commitMessage = config.getCommitMessage();
if (!commitMessage.isEmpty()) {
- checkinPanel.setCommitMessage(commitMessage);
+ if (config.getAppendMode()) {
+ checkinPanel.setCommitMessage(checkinPanel.getCommitMessage() + " " + commitMessage);
+ } else {
+ checkinPanel.setCommitMessage(commitMessage);
+ }
}
}
}
@Nullable
- private static CommitMessageI getCheckinPanel(@Nullable AnActionEvent e) {
+ private static CheckinProjectPanel getCheckinPanel(@Nullable AnActionEvent e) {
if (e == null) {
return null;
}
Refreshable data = Refreshable.PANEL_KEY.getData(e.getDataContext());
- if (data instanceof CommitMessageI) {
- return (CommitMessageI) data;
- }
- CommitMessageI commitMessageI = VcsDataKeys.COMMIT_MESSAGE_CONTROL.getData(e.getDataContext());
- if (commitMessageI != null) {
- return commitMessageI;
+ if (data instanceof CheckinProjectPanel) {
+ return (CheckinProjectPanel) data;
}
+ // Unsure what to do with this. Can't get the current commitMessage from a commitMessageI.
+// CommitMessageI commitMessageI = VcsDataKeys.COMMIT_MESSAGE_CONTROL.getData(e.getDataContext());
+// if (commitMessageI != null) {
+// return commitMessageI;
+// }
return null;
}
}
diff --git a/src/commitmessagetemplate/CommitMessageTemplateConfig.java b/src/commitmessagetemplate/CommitMessageTemplateConfig.java
index d2340dd..af65904 100644
--- a/src/commitmessagetemplate/CommitMessageTemplateConfig.java
+++ b/src/commitmessagetemplate/CommitMessageTemplateConfig.java
@@ -48,6 +48,9 @@ String getCommentChar() {
return cmState.commentChar;
}
+ boolean getAppendMode() {
+ return cmState.append;
+ }
void setCommitMessage(String commitMessage) {
cmState.manualTemplate = commitMessage;
}
@@ -64,6 +67,10 @@ void setCommentChar(String commentChar) {
cmState.commentChar = commentChar;
}
+ void setAppend(boolean append) {
+ cmState.append = append;
+ }
+
@Nullable
@Override
public CommitState getState() {
@@ -85,6 +92,7 @@ public static class CommitState {
public boolean radioState = true;
public String templateFilePath = "";
public String commentChar = "";
+ public boolean append = false;
}
private String OpenFile(String configFilePath) {
diff --git a/src/commitmessagetemplate/CommitMessageTemplateConfigurableGUI.form b/src/commitmessagetemplate/CommitMessageTemplateConfigurableGUI.form
index cde8a35..0086fdf 100644
--- a/src/commitmessagetemplate/CommitMessageTemplateConfigurableGUI.form
+++ b/src/commitmessagetemplate/CommitMessageTemplateConfigurableGUI.form
@@ -8,7 +8,7 @@
-
+
@@ -54,7 +54,7 @@
-
+
@@ -62,7 +62,7 @@
-
+
@@ -70,6 +70,14 @@
+
+
+
+
+
+
+
+
diff --git a/src/commitmessagetemplate/CommitMessageTemplateConfigurableGUI.java b/src/commitmessagetemplate/CommitMessageTemplateConfigurableGUI.java
index 5674730..7bde684 100644
--- a/src/commitmessagetemplate/CommitMessageTemplateConfigurableGUI.java
+++ b/src/commitmessagetemplate/CommitMessageTemplateConfigurableGUI.java
@@ -20,6 +20,7 @@ public class CommitMessageTemplateConfigurableGUI {
private TextFieldWithBrowseButton templateFilePath;
private JTextField commentChar;
private JLabel commentCharLabel;
+ private JCheckBox append;
private CommitMessageTemplateConfig config;
private FileChooserDescriptor descriptor = FileChooserDescriptorFactory.createSingleFileDescriptor("txt");
@@ -55,6 +56,7 @@ public void actionPerformed(ActionEvent e) {
templateFilePath.setEnabled(!config.getRadioStatus());
commentChar.setEnabled(!config.getRadioStatus());
commentChar.setText(config.getCommentChar());
+ append.setSelected(config.getAppendMode());
}
}
@@ -66,7 +68,8 @@ boolean isModified() {
return !commitMessageTextBox.getText().equals(config.getManualTemplate()) ||
!setTemplateRadioButton.isSelected() == config.getRadioStatus() ||
!templateFilePath.getText().equals(config.getTemplateFilePath()) ||
- !commentChar.getText().equals(config.getCommentChar());
+ !commentChar.getText().equals(config.getCommentChar()) ||
+ !append.isSelected() == config.getAppendMode();
}
void apply() {
@@ -74,6 +77,7 @@ void apply() {
config.setRadioStatus(setTemplateRadioButton.isSelected());
config.setTemplateFilePath(templateFilePath.getText());
config.setCommentChar(commentChar.getText());
+ config.setAppend(append.isSelected());
}
void reset() {
@@ -84,6 +88,7 @@ void reset() {
templateFilePath.setEnabled(!config.getRadioStatus());
commentChar.setEnabled(!config.getRadioStatus());
commentChar.setText(config.getCommentChar());
+ append.setSelected(config.getAppendMode());
}