Skip to content

Commit

Permalink
Closes aleksandr-m#14 - Allow to rebase or merge w/o no-ff option in …
Browse files Browse the repository at this point in the history
…release goals
  • Loading branch information
aleksandr-m committed May 23, 2016
1 parent d43bf7f commit 0bc526b
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*
Expand All @@ -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);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>true</code> then rebase will
* be performed.
*
* @since 1.2.3
*/
@Parameter(property = "releaseRebase", defaultValue = "false")
private boolean releaseRebase = false;

/**
* Whether to use <code>--no-ff</code> option when merging.
*
* @since 1.2.3
*/
@Parameter(property = "releaseMergeNoFF", defaultValue = "true")
private boolean releaseMergeNoFF = true;

/** {@inheritDoc} */
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
Expand Down Expand Up @@ -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();
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 <code>true</code> then rebase will
* be performed.
*
* @since 1.2.3
*/
@Parameter(property = "releaseRebase", defaultValue = "false")
private boolean releaseRebase = false;

/**
* Whether to use <code>--no-ff</code> option when merging.
*
* @since 1.2.3
*/
@Parameter(property = "releaseMergeNoFF", defaultValue = "true")
private boolean releaseMergeNoFF = true;

/** {@inheritDoc} */
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
Expand Down Expand Up @@ -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)) {
Expand Down

0 comments on commit 0bc526b

Please sign in to comment.