Skip to content

Commit

Permalink
Allow to change support branch name - closes #276
Browse files Browse the repository at this point in the history
  • Loading branch information
aleksandr-m committed Feb 4, 2021
1 parent 6ad3bea commit 284607b
Showing 1 changed file with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,13 @@ public class GitFlowSupportStartMojo extends AbstractGitFlowMojo {
@Parameter(property = "tagName")
private String tagName;

/**
* Branch name to use instead of the default.
*
*/
@Parameter(property = "supportBranchName")
private String supportBranchName;

/** {@inheritDoc} */
@Override
public void execute() throws MojoExecutionException, MojoFailureException {
Expand Down Expand Up @@ -91,25 +98,28 @@ public void execute() throws MojoExecutionException, MojoFailureException {
throw new MojoFailureException("Tag is blank.");
}

String branchName = tag;
if (StringUtils.isNotBlank(supportBranchName)) {
branchName = supportBranchName;
}

// git for-each-ref refs/heads/support/...
final boolean supportBranchExists = gitCheckBranchExists(gitFlowConfig
.getSupportBranchPrefix() + tag);
final boolean supportBranchExists = gitCheckBranchExists(gitFlowConfig.getSupportBranchPrefix() + branchName);

if (supportBranchExists) {
throw new MojoFailureException(
"Support branch with that name already exists.");
throw new MojoFailureException("Support branch with that name already exists.");
}

// git checkout -b ... tag
gitCreateAndCheckout(gitFlowConfig.getSupportBranchPrefix() + tag, tag);
gitCreateAndCheckout(gitFlowConfig.getSupportBranchPrefix() + branchName, tag);

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

if (pushRemote) {
gitPush(gitFlowConfig.getSupportBranchPrefix() + tag, false);
gitPush(gitFlowConfig.getSupportBranchPrefix() + branchName, false);
}
} catch (CommandLineException e) {
throw new MojoFailureException("support-start", e);
Expand Down

0 comments on commit 284607b

Please sign in to comment.