diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java index bc14eee0..95fcf6f0 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/AbstractGitFlowMojo.java @@ -386,6 +386,28 @@ protected void gitCommit(final String message) throws MojoFailureException, executeGitCommand("commit", "-a", "-m", message); } + /** + * Executes git rebase or git merge --no-ff or git merge. + * + * @param branchName + * Branch name to merge. + * @throws MojoFailureException + * @throws CommandLineException + */ + protected void gitMerge(final String branchName, boolean rebase, + boolean noff) throws MojoFailureException, CommandLineException { + if (rebase) { + getLog().info("Rebasing '" + branchName + "' branch."); + executeGitCommand("rebase", branchName); + } else if (noff) { + getLog().info("Merging (--no-ff) '" + branchName + "' branch."); + executeGitCommand("merge", "--no-ff", branchName); + } else { + getLog().info("Merging '" + branchName + "' branch."); + executeGitCommand("merge", branchName); + } + } + /** * Executes git merge --no-ff. * @@ -396,9 +418,7 @@ protected void gitCommit(final String message) throws MojoFailureException, */ protected void gitMergeNoff(final String branchName) throws MojoFailureException, CommandLineException { - getLog().info("Merging '" + branchName + "' branch."); - - executeGitCommand("merge", "--no-ff", branchName); + gitMerge(branchName, false, true); } /** diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseFinishMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseFinishMojo.java index bdc25066..5c18d1a9 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseFinishMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseFinishMojo.java @@ -51,6 +51,23 @@ public class GitFlowReleaseFinishMojo extends AbstractGitFlowMojo { @Parameter(property = "skipTestProject", defaultValue = "false") private boolean skipTestProject = false; + /** + * Whether to rebase branch or merge. If true then rebase will + * be performed. + * + * @since 1.2.3 + */ + @Parameter(property = "releaseRebase", defaultValue = "false") + private boolean releaseRebase = false; + + /** + * Whether to use --no-ff option when merging. + * + * @since 1.2.3 + */ + @Parameter(property = "releaseMergeNoFF", defaultValue = "true") + private boolean releaseMergeNoFF = true; + /** {@inheritDoc} */ @Override public void execute() throws MojoExecutionException, MojoFailureException { @@ -86,8 +103,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { // git checkout master gitCheckout(gitFlowConfig.getProductionBranch()); - // git merge --no-ff release/... - gitMergeNoff(releaseBranch); + gitMerge(releaseBranch, releaseRebase, releaseMergeNoFF); // get current project version from pom final String currentVersion = getCurrentProjectVersion(); @@ -107,8 +123,7 @@ public void execute() throws MojoExecutionException, MojoFailureException { // git checkout develop gitCheckout(gitFlowConfig.getDevelopmentBranch()); - // git merge --no-ff release/... - gitMergeNoff(releaseBranch); + gitMerge(releaseBranch, releaseRebase, releaseMergeNoFF); String nextSnapshotVersion = null; // get next snapshot version diff --git a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseMojo.java b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseMojo.java index 6ecfdef2..b0e1a3c6 100644 --- a/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseMojo.java +++ b/src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowReleaseMojo.java @@ -48,6 +48,23 @@ public class GitFlowReleaseMojo extends AbstractGitFlowMojo { @Parameter(property = "skipTestProject", defaultValue = "false") private boolean skipTestProject = false; + /** + * Whether to rebase branch or merge. If true then rebase will + * be performed. + * + * @since 1.2.3 + */ + @Parameter(property = "releaseRebase", defaultValue = "false") + private boolean releaseRebase = false; + + /** + * Whether to use --no-ff option when merging. + * + * @since 1.2.3 + */ + @Parameter(property = "releaseMergeNoFF", defaultValue = "true") + private boolean releaseMergeNoFF = true; + /** {@inheritDoc} */ @Override public void execute() throws MojoExecutionException, MojoFailureException { @@ -131,8 +148,8 @@ public void execute() throws MojoExecutionException, MojoFailureException { // git checkout master gitCheckout(gitFlowConfig.getProductionBranch()); - // git merge --no-ff develop/... - gitMergeNoff(gitFlowConfig.getDevelopmentBranch()); + gitMerge(gitFlowConfig.getDevelopmentBranch(), releaseRebase, + releaseMergeNoFF); if (!skipTag) { if (tychoBuild && ArtifactUtils.isSnapshot(version)) {