Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -342,7 +342,7 @@ protected boolean validBranchName(final String branchName)
* @throws CommandLineException
* @throws MojoFailureException
*/
private boolean executeGitHasUncommitted() throws MojoFailureException,
protected boolean executeGitHasUncommitted() throws MojoFailureException,
CommandLineException {
boolean uncommited = false;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,11 @@ public void execute() throws MojoExecutionException, MojoFailureException {
if (featureSquash) {
// git merge --squash feature/...
gitMergeSquash(featureBranchName);
gitCommit(featureBranchName);
if (executeGitHasUncommitted()) {
gitCommit(featureBranchName);
} else {
getLog().info("No changes detected. Did you manually merge '" + featureBranchName + "' branch into '"+gitFlowConfig.getDevelopmentBranch()+"'?");
}
} else {
// git merge --no-ff feature/...
gitMergeNoff(featureBranchName, commitMessages.getFeatureFinishDevMergeMessage(), null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ public class GitFlowHotfixFinishMojo extends AbstractGitFlowMojo {
@Parameter(property = "skipTag", defaultValue = "false")
private boolean skipTag = false;

/** Whether to fail if tag exists the hotfix in Git (such as when already merged). */
@Parameter(property = "failIfTagExists", defaultValue = "true")
private boolean failIfTagExists = true;

/** Whether to keep hotfix branch after finish. */
@Parameter(property = "keepBranch", defaultValue = "false")
private boolean keepBranch = false;
Expand Down Expand Up @@ -227,8 +231,12 @@ public void execute() throws MojoExecutionException, MojoFailureException {
properties.put("version", tagVersion);

// git tag -a ...
gitTag(gitFlowConfig.getVersionTagPrefix() + tagVersion,
commitMessages.getTagHotfixMessage(), gpgSignTag, properties);
String tagName = gitFlowConfig.getVersionTagPrefix() + tagVersion;
if (! gitCheckTagExists(tagName) || failIfTagExists) {
gitTag(tagName, commitMessages.getTagHotfixMessage(), gpgSignTag, properties);
} else if (! failIfTagExists) {
getLog().warn("Tag '" + tagName + "' already exists, But '-DfailIfTagExists' set to false.");
}
}

if (skipMergeProdBranch && (supportBranchName == null)) {
Expand All @@ -248,6 +256,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
gitFlowConfig.getReleaseBranchPrefix(), true);

if (supportBranchName == null) {

// if release branch exists merge hotfix changes into it
if (StringUtils.isNotBlank(releaseBranch)) {
// git checkout release
Expand All @@ -271,6 +280,9 @@ public void execute() throws MojoExecutionException, MojoFailureException {
gitCommit(commitMessages.getUpdateReleaseBackPreMergeStateMessage());
}
} else if (!skipMergeDevBranch) {
// I should update the DEV version only if the hotfix
// version is superior to the DEV version
boolean shouldIncrementDevVersion = true;
GitFlowVersionInfo developVersionInfo = new GitFlowVersionInfo(
currentVersion);
if (notSameProdDevName()) {
Expand All @@ -281,7 +293,11 @@ public void execute() throws MojoExecutionException, MojoFailureException {

// set version to avoid merge conflict
mvnSetVersions(currentVersion);
gitCommit(commitMessages.getHotfixVersionUpdateMessage());
if (executeGitHasUncommitted()) {
gitCommit(commitMessages.getHotfixVersionUpdateMessage());
} else {
getLog().info("No changes detected. Did you manually merge '" + currentVersion + "' branch into '"+gitFlowConfig.getDevelopmentBranch()+"'?");
}

messageProperties.put("version", currentVersion);

Expand All @@ -293,18 +309,24 @@ public void execute() throws MojoExecutionException, MojoFailureException {
GitFlowVersionInfo hotfixVersionInfo = new GitFlowVersionInfo(
currentVersion);
if (developVersionInfo
.compareTo(hotfixVersionInfo) < 0) {
.compareTo(hotfixVersionInfo) <= 0) {
developVersionInfo = hotfixVersionInfo;
} else {
shouldIncrementDevVersion = false;
}
}

// get next snapshot version
final String nextSnapshotVersion = developVersionInfo.nextSnapshotVersion();

if (StringUtils.isBlank(nextSnapshotVersion)) {
throw new MojoFailureException(

String nextSnapshotVersion = developVersionInfo.getSnapshotVersionString();
if (shouldIncrementDevVersion) {
// get next snapshot version
nextSnapshotVersion = developVersionInfo.nextSnapshotVersion();

if (StringUtils.isBlank(nextSnapshotVersion)) {
throw new MojoFailureException(
"Next snapshot version is blank.");
}
}


// mvn versions:set -DnewVersion=...
// -DgenerateBackupPoms=false
Expand All @@ -315,12 +337,12 @@ public void execute() throws MojoExecutionException, MojoFailureException {

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

if (installProject) {
// mvn clean install
// mvn clean install
mvnCleanInstall();
}

Expand Down