Skip to content

Commit

Permalink
Closes aleksandr-m#8 - Enable to customize commit messages
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandr-m committed Dec 17, 2015
1 parent 798d8bb commit ecd0b2e
Show file tree
Hide file tree
Showing 9 changed files with 185 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
@Parameter(defaultValue = "${gitFlowConfig}")
protected GitFlowConfig gitFlowConfig;

/** Git commit messages. */
@Parameter(defaultValue = "${commitMessages}")
protected CommitMessages commitMessages;

/** Whether this is Tycho build. */
@Parameter(defaultValue = "false")
protected boolean tychoBuild;
Expand Down
170 changes: 170 additions & 0 deletions src/main/java/com/amashchenko/maven/plugin/gitflow/CommitMessages.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,170 @@
/*
* Copyright 2014-2015 Aleksandr Mashchenko.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.amashchenko.maven.plugin.gitflow;

/**
* Git commit messages.
*
* @author Aleksandr Mashchenko
*
*/
public class CommitMessages {
private String featureStartMessage;
private String featureFinishMessage;

private String hotfixStartMessage;
private String hotfixFinishMessage;

private String releaseStartMessage;
private String releaseFinishMessage;

private String tagHotfixMessage;
private String tagReleaseMessage;

public CommitMessages() {
featureStartMessage = "updating versions for feature branch";
featureFinishMessage = "updating versions for development branch";

hotfixStartMessage = "updating versions for hotfix";
hotfixFinishMessage = "updating for next development version";

releaseStartMessage = "updating versions for release";
releaseFinishMessage = "updating for next development version";

tagHotfixMessage = "tagging hotfix";
tagReleaseMessage = "tagging release";
}

/**
* @return the featureStartMessage
*/
public String getFeatureStartMessage() {
return featureStartMessage;
}

/**
* @param featureStartMessage
* the featureStartMessage to set
*/
public void setFeatureStartMessage(String featureStartMessage) {
this.featureStartMessage = featureStartMessage;
}

/**
* @return the featureFinishMessage
*/
public String getFeatureFinishMessage() {
return featureFinishMessage;
}

/**
* @param featureFinishMessage
* the featureFinishMessage to set
*/
public void setFeatureFinishMessage(String featureFinishMessage) {
this.featureFinishMessage = featureFinishMessage;
}

/**
* @return the hotfixStartMessage
*/
public String getHotfixStartMessage() {
return hotfixStartMessage;
}

/**
* @param hotfixStartMessage
* the hotfixStartMessage to set
*/
public void setHotfixStartMessage(String hotfixStartMessage) {
this.hotfixStartMessage = hotfixStartMessage;
}

/**
* @return the hotfixFinishMessage
*/
public String getHotfixFinishMessage() {
return hotfixFinishMessage;
}

/**
* @param hotfixFinishMessage
* the hotfixFinishMessage to set
*/
public void setHotfixFinishMessage(String hotfixFinishMessage) {
this.hotfixFinishMessage = hotfixFinishMessage;
}

/**
* @return the releaseStartMessage
*/
public String getReleaseStartMessage() {
return releaseStartMessage;
}

/**
* @param releaseStartMessage
* the releaseStartMessage to set
*/
public void setReleaseStartMessage(String releaseStartMessage) {
this.releaseStartMessage = releaseStartMessage;
}

/**
* @return the releaseFinishMessage
*/
public String getReleaseFinishMessage() {
return releaseFinishMessage;
}

/**
* @param releaseFinishMessage
* the releaseFinishMessage to set
*/
public void setReleaseFinishMessage(String releaseFinishMessage) {
this.releaseFinishMessage = releaseFinishMessage;
}

/**
* @return the tagHotfixMessage
*/
public String getTagHotfixMessage() {
return tagHotfixMessage;
}

/**
* @param tagHotfixMessage
* the tagHotfixMessage to set
*/
public void setTagHotfixMessage(String tagHotfixMessage) {
this.tagHotfixMessage = tagHotfixMessage;
}

/**
* @return the tagReleaseMessage
*/
public String getTagReleaseMessage() {
return tagReleaseMessage;
}

/**
* @param tagReleaseMessage
* the tagReleaseMessage to set
*/
public void setTagReleaseMessage(String tagReleaseMessage) {
this.tagReleaseMessage = tagReleaseMessage;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
mvnSetVersions(version);

// git commit -a -m updating versions for development branch
gitCommit("updating versions for development branch");
gitCommit(commitMessages.getFeatureFinishMessage());
}

if (installProject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
mvnSetVersions(version);

// git commit -a -m updating versions for feature branch
gitCommit("updating versions for feature branch");
gitCommit(commitMessages.getFeatureStartMessage());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {

// git tag -a ...
gitTag(gitFlowConfig.getVersionTagPrefix() + tagVersion,
"tagging hotfix");
commitMessages.getTagHotfixMessage());
}

// check whether release branch exists
Expand Down Expand Up @@ -168,7 +168,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
mvnSetVersions(nextSnapshotVersion);

// git commit -a -m updating for next development version
gitCommit("updating for next development version");
gitCommit(commitMessages.getHotfixFinishMessage());
}

if (installProject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
mvnSetVersions(version);

// git commit -a -m updating versions for hotfix
gitCommit("updating versions for hotfix");
gitCommit(commitMessages.getHotfixStartMessage());
}

if (installProject) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {

// git tag -a ...
gitTag(gitFlowConfig.getVersionTagPrefix() + tagVersion,
"tagging release");
commitMessages.getTagReleaseMessage());
}

// git checkout develop
Expand Down Expand Up @@ -123,7 +123,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
mvnSetVersions(nextSnapshotVersion);

// git commit -a -m updating for next development version
gitCommit("updating for next development version");
gitCommit(commitMessages.getReleaseFinishMessage());

if (installProject) {
// mvn clean install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
mvnSetVersions(version);

// git commit -a -m updating versions for release
gitCommit("updating versions for release");
gitCommit(commitMessages.getReleaseStartMessage());
}

// git checkout master
Expand All @@ -133,7 +133,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {

// git tag -a ...
gitTag(gitFlowConfig.getVersionTagPrefix() + version,
"tagging release");
commitMessages.getTagReleaseMessage());
}

// git checkout develop
Expand Down Expand Up @@ -161,7 +161,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
mvnSetVersions(nextSnapshotVersion);

// git commit -a -m updating for next development version
gitCommit("updating for next development version");
gitCommit(commitMessages.getReleaseFinishMessage());

if (installProject) {
// mvn clean install
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
mvnSetVersions(version);

// git commit -a -m updating versions for release
gitCommit("updating versions for release");
gitCommit(commitMessages.getReleaseStartMessage());
}

if (installProject) {
Expand Down

0 comments on commit ecd0b2e

Please sign in to comment.