Skip to content
Permalink

Comparing changes

This is a direct comparison between two commits made in this repository or its related repositories. View the default comparison for this range or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: aleksandr-m/gitflow-maven-plugin
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 01f5b386478f5eb4348ab516a44aeb7bf268deec
Choose a base ref
..
head repository: aleksandr-m/gitflow-maven-plugin
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 6dc1059d6324ebe8903ea80375a1b9790b30b06d
Choose a head ref
Original file line number Diff line number Diff line change
@@ -53,6 +53,7 @@ public class CommitMessages {
private String updateReleaseBackPreMergeStateMessage;

private String updateFeatureBackMessage;
private String featureFinishIncrementVersionMessage;

public CommitMessages() {
featureStartMessage = "Update versions for feature branch";
@@ -81,6 +82,7 @@ public CommitMessages() {
updateReleaseBackPreMergeStateMessage = "Update release version back to pre-merge state";

updateFeatureBackMessage = "Update feature branch back to feature version";
featureFinishIncrementVersionMessage = "Increment feature version";
}

/**
@@ -406,4 +408,19 @@ public String getUpdateFeatureBackMessage() {
public void setUpdateFeatureBackMessage(String updateFeatureBackMessage) {
this.updateFeatureBackMessage = updateFeatureBackMessage;
}

/**
* @return the featureFinishIncrementVersionMessage
*/
public String getFeatureFinishIncrementVersionMessage() {
return featureFinishIncrementVersionMessage;
}

/**
* @param featureFinishIncrementVersionMessage
* the featureFinishIncrementVersionMessage to set
*/
public void setFeatureFinishIncrementVersionMessage(String featureFinishIncrementVersionMessage) {
this.featureFinishIncrementVersionMessage = featureFinishIncrementVersionMessage;
}
}
Original file line number Diff line number Diff line change
@@ -89,6 +89,12 @@ public class GitFlowFeatureFinishMojo extends AbstractGitFlowMojo {
@Parameter(property = "postFeatureFinishGoals")
private String postFeatureFinishGoals;

/**
* Whether to increment the version during feature-finish goal.
*
*/
@Parameter(property = "incrementVersionAtFinish", defaultValue = "false")
private boolean incrementVersionAtFinish;

/** {@inheritDoc} */
@Override
@@ -138,13 +144,26 @@ public void execute() throws MojoExecutionException, MojoFailureException {
mvnRun(preFeatureFinishGoals);
}

final String currentFeatureVersion = getCurrentProjectVersion();
String featureVersion = getCurrentProjectVersion();

final String featName = featureBranchName.replaceFirst(gitFlowConfig.getFeatureBranchPrefix(), "");

if (currentFeatureVersion.contains("-" + featName)) {
final String version = currentFeatureVersion.replaceFirst("-" + featName, "");
if (incrementVersionAtFinish) {
GitFlowVersionInfo developVersionInfo = new GitFlowVersionInfo(featureVersion);
featureVersion = developVersionInfo.nextSnapshotVersion();

mvnSetVersions(featureVersion);

Map<String, String> properties = new HashMap<String, String>();
properties.put("version", featureVersion);
properties.put("featureName", featName);
gitCommit(commitMessages.getFeatureFinishIncrementVersionMessage(), properties);
}

final String keptFeatureVersion = featureVersion;

final String version = keptFeatureVersion.replaceFirst("-" + featName, "");
if (keptFeatureVersion.contains("-" + featName)) {
// mvn versions:set -DnewVersion=... -DgenerateBackupPoms=false
mvnSetVersions(version);

@@ -164,8 +183,11 @@ public void execute() throws MojoExecutionException, MojoFailureException {
gitMergeSquash(featureBranchName);
gitCommit(featureBranchName);
} else {
Map<String, String> properties = new HashMap<String, String>();
properties.put("version", version);
properties.put("featureName", featName);
// git merge --no-ff feature/...
gitMergeNoff(featureBranchName, commitMessages.getFeatureFinishDevMergeMessage(), null);
gitMergeNoff(featureBranchName, commitMessages.getFeatureFinishDevMergeMessage(), properties);
}

// maven goals after merge
@@ -181,10 +203,10 @@ public void execute() throws MojoExecutionException, MojoFailureException {
if (keepBranch) {
gitCheckout(featureBranchName);

mvnSetVersions(currentFeatureVersion);
mvnSetVersions(keptFeatureVersion);

Map<String, String> properties = new HashMap<String, String>();
properties.put("version", currentFeatureVersion);
properties.put("version", keptFeatureVersion);
properties.put("featureName", featName);

gitCommit(commitMessages.getUpdateFeatureBackMessage(), properties);