Skip to content

Commit 284607b

Browse files
committed
Allow to change support branch name - closes #276
1 parent 6ad3bea commit 284607b

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/main/java/com/amashchenko/maven/plugin/gitflow/GitFlowSupportStartMojo.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,13 @@ public class GitFlowSupportStartMojo extends AbstractGitFlowMojo {
4949
@Parameter(property = "tagName")
5050
private String tagName;
5151

52+
/**
53+
* Branch name to use instead of the default.
54+
*
55+
*/
56+
@Parameter(property = "supportBranchName")
57+
private String supportBranchName;
58+
5259
/** {@inheritDoc} */
5360
@Override
5461
public void execute() throws MojoExecutionException, MojoFailureException {
@@ -91,25 +98,28 @@ public void execute() throws MojoExecutionException, MojoFailureException {
9198
throw new MojoFailureException("Tag is blank.");
9299
}
93100

101+
String branchName = tag;
102+
if (StringUtils.isNotBlank(supportBranchName)) {
103+
branchName = supportBranchName;
104+
}
105+
94106
// git for-each-ref refs/heads/support/...
95-
final boolean supportBranchExists = gitCheckBranchExists(gitFlowConfig
96-
.getSupportBranchPrefix() + tag);
107+
final boolean supportBranchExists = gitCheckBranchExists(gitFlowConfig.getSupportBranchPrefix() + branchName);
97108

98109
if (supportBranchExists) {
99-
throw new MojoFailureException(
100-
"Support branch with that name already exists.");
110+
throw new MojoFailureException("Support branch with that name already exists.");
101111
}
102112

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

106116
if (installProject) {
107117
// mvn clean install
108118
mvnCleanInstall();
109119
}
110120

111121
if (pushRemote) {
112-
gitPush(gitFlowConfig.getSupportBranchPrefix() + tag, false);
122+
gitPush(gitFlowConfig.getSupportBranchPrefix() + branchName, false);
113123
}
114124
} catch (CommandLineException e) {
115125
throw new MojoFailureException("support-start", e);

0 commit comments

Comments
 (0)