Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New parameter for additionalMergeOptions #157

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
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
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,11 @@ Release branch can be merged with `--ff-only` option by setting `releaseMergeFFO

Feature branch can be squashed before merging by setting `featureSquash` parameter to `true`. The default value is `false` (i.e. merge w/o squash will be performed).

You can also specify the optional parameter `additionalMergeOptions` for goals with merge-operations. It takes an arbitrary string, that will be appended to the merge-command. This is useful when in need for advanced options like `-Xtheirs`.

For the `gitflow:hotfix-finish` and `gitflow:release-finish` goals it is also possible to specify different merge-options for merging into master and development-branch:
`productionBranchMergeOptions` and `devBranchMergeOptions`.

### Running custom Maven goals

The `preReleaseGoals` parameter can be used in `gitflow:release-finish` and `gitflow:release` goals to run defined Maven goals before the release.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ public abstract class AbstractGitFlowMojo extends AbstractMojo {
@Parameter(defaultValue = "${settings}", readonly = true)
protected Settings settings;

@Parameter(property = "additionalMergeOptions")
protected String additionalMergeOptions;

/**
* Initializes command line executables.
*
Expand Down Expand Up @@ -622,7 +625,7 @@ protected void gitCommit(String message, Map<String, String> messageProperties)

/**
* Executes git rebase or git merge --ff-only or git merge --no-ff or git merge.
*
*
* @param branchName
* Branch name to merge.
* @param rebase
Expand All @@ -641,6 +644,31 @@ protected void gitCommit(String message, Map<String, String> messageProperties)
protected void gitMerge(final String branchName, boolean rebase, boolean noff, boolean ffonly, String message,
Map<String, String> messageProperties)
throws MojoFailureException, CommandLineException {
gitMerge(branchName, rebase, noff, ffonly, message, messageProperties, additionalMergeOptions);
}

/**
* Executes git rebase or git merge --ff-only or git merge --no-ff or git merge.
*
* @param branchName
* Branch name to merge.
* @param rebase
* Do rebase.
* @param noff
* Merge with --no-ff.
* @param ffonly
* Merge with --ff-only.
* @param message
* Merge commit message.
* @param additionalMergeOptions
* additional commandline options for the merge e.g. "-Xtheirs"
*
* @throws MojoFailureException
* @throws CommandLineException
*/
protected void gitMerge(final String branchName, boolean rebase, boolean noff, boolean ffonly,
final String message, Map<String, String> messageProperties, final String additionalMergeOptions)
throws MojoFailureException, CommandLineException {
String sign = "";
if (gpgSignCommit) {
sign = "-S";
Expand All @@ -653,16 +681,16 @@ protected void gitMerge(final String branchName, boolean rebase, boolean noff, b
}
if (rebase) {
getLog().info("Rebasing '" + branchName + "' branch.");
executeGitCommand("rebase", sign, branchName);
executeGitCommand("rebase", additionalMergeOptions, sign, branchName);
} else if (ffonly) {
getLog().info("Merging (--ff-only) '" + branchName + "' branch.");
executeGitCommand("merge", "--ff-only", sign, branchName);
executeGitCommand("merge", additionalMergeOptions, "--ff-only", sign, branchName);
} else if (noff) {
getLog().info("Merging (--no-ff) '" + branchName + "' branch.");
executeGitCommand("merge", "--no-ff", sign, branchName, msgParam, msg);
executeGitCommand("merge", additionalMergeOptions, "--no-ff", sign, branchName, msgParam, msg);
} else {
getLog().info("Merging '" + branchName + "' branch.");
executeGitCommand("merge", sign, branchName, msgParam, msg);
executeGitCommand("merge", additionalMergeOptions, sign, branchName, msgParam, msg);
}
}

Expand All @@ -676,7 +704,24 @@ protected void gitMerge(final String branchName, boolean rebase, boolean noff, b
*/
protected void gitMergeNoff(final String branchName)
throws MojoFailureException, CommandLineException {
gitMerge(branchName, false, true, false, null, null);
gitMergeNoff(branchName, additionalMergeOptions);
}

/**
* Executes git merge --no-ff.
*
* @param branchName
* Branch name to merge.
*
* @param additionalMergeOptions
* additional commandline options for the merge e.g. "-Xtheirs"
*
* @throws MojoFailureException
* @throws CommandLineException
*/
protected void gitMergeNoff(final String branchName, final String additionalMergeOptions)
throws MojoFailureException, CommandLineException {
gitMerge(branchName, false, true, false, null, null, additionalMergeOptions);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,12 @@ public class GitFlowHotfixFinishMojo extends AbstractGitFlowMojo {
@Parameter(property = "skipMergeDevBranch", defaultValue = "false")
private boolean skipMergeDevBranch = false;

@Parameter(property = "productionBranchMergeOptions")
private String productionBranchMergeOptions;

@Parameter(property = "devBranchMergeOptions")
private String devBranchMergeOptions;

/** {@inheritDoc} */
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
Expand Down Expand Up @@ -199,7 +205,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}

// git merge --no-ff hotfix/...
gitMergeNoff(hotfixBranchName);
gitMergeNoff(hotfixBranchName, productionBranchMergeOptions);

final String currentVersion = getCurrentProjectVersion();

Expand Down Expand Up @@ -243,7 +249,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}

// git merge --no-ff hotfix/...
gitMergeNoff(hotfixBranchName);
gitMergeNoff(hotfixBranchName, devBranchMergeOptions);

if (!currentVersion.equals(releaseBranchVersion)) {
mvnSetVersions(releaseBranchVersion);
Expand All @@ -263,7 +269,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
gitCommit(commitMessages.getHotfixVersionUpdateMessage());

// git merge --no-ff hotfix/...
gitMergeNoff(hotfixBranchName);
gitMergeNoff(hotfixBranchName, devBranchMergeOptions);

// which version to increment
GitFlowVersionInfo hotfixVersionInfo = new GitFlowVersionInfo(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ public class GitFlowReleaseFinishMojo extends AbstractGitFlowMojo {
@Parameter(property = "useSnapshotInRelease", defaultValue = "false")
private boolean useSnapshotInRelease;

@Parameter(property = "productionBranchMergeOptions")
private String productionBranchMergeOptions;

@Parameter(property = "devBranchMergeOptions")
private String devBranchMergeOptions;

/** {@inheritDoc} */
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
Expand Down Expand Up @@ -239,7 +245,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
gitCheckout(gitFlowConfig.getProductionBranch());

gitMerge(releaseBranch, releaseRebase, releaseMergeNoFF, releaseMergeFFOnly,
commitMessages.getReleaseFinishMergeMessage(), messageProperties);
commitMessages.getReleaseFinishMergeMessage(), messageProperties, productionBranchMergeOptions);

// get current project version from pom
final String currentVersion = getCurrentProjectVersion();
Expand Down Expand Up @@ -278,7 +284,7 @@ public void execute() throws MojoExecutionException, MojoFailureException {
}

// merge branch master into develop
gitMerge(releaseBranch, releaseRebase, releaseMergeNoFF, false, null, null);
gitMerge(releaseBranch, releaseRebase, releaseMergeNoFF, false, null, null, devBranchMergeOptions);

if (commitDevelopmentVersionAtStart && useSnapshotInRelease) {
// updating develop poms version back to pre merge state
Expand Down