@@ -128,6 +128,17 @@ public class GitFlowHotfixFinishMojo extends AbstractGitFlowMojo {
128128 @ Parameter (property = "skipMergeDevBranch" , defaultValue = "false" )
129129 private boolean skipMergeDevBranch = false ;
130130
131+ /**
132+ * Controls which branch is merged to develop branch. If set to
133+ * <code>true</code> then hotfix branch will be merged to develop. If set to
134+ * <code>false</code> and tag is present ({@link #skipTag} is set to
135+ * <code>false</code>) then tag will be merged. If there is no tag then
136+ * production branch will be merged to develop.
137+ *
138+ */
139+ @ Parameter (property = "noBackMergeHotfix" , defaultValue = "false" )
140+ private boolean noBackMergeHotfix = false ;
141+
131142 /** {@inheritDoc} */
132143 @ Override
133144 public void execute () throws MojoExecutionException , MojoFailureException {
@@ -229,13 +240,10 @@ public void execute() throws MojoExecutionException, MojoFailureException {
229240
230241 final String currentVersion = getCurrentProjectVersion ();
231242
243+ final String tagVersion = (tychoBuild || useSnapshotInHotfix ) && ArtifactUtils .isSnapshot (currentVersion )
244+ ? currentVersion .replace ("-" + Artifact .SNAPSHOT_VERSION , "" )
245+ : currentVersion ;
232246 if (!skipTag ) {
233- String tagVersion = currentVersion ;
234- if ((tychoBuild || useSnapshotInHotfix ) && ArtifactUtils .isSnapshot (tagVersion )) {
235- tagVersion = tagVersion
236- .replace ("-" + Artifact .SNAPSHOT_VERSION , "" );
237- }
238-
239247 Map <String , String > properties = new HashMap <>();
240248 properties .put ("version" , tagVersion );
241249
@@ -297,9 +305,15 @@ public void execute() throws MojoExecutionException, MojoFailureException {
297305
298306 messageProperties .put ("version" , currentVersion );
299307
300- // git merge --no-ff hotfix/...
301- gitMergeNoff (hotfixBranchName , commitMessages .getHotfixFinishDevMergeMessage (),
302- messageProperties );
308+ final String refToMerge ;
309+ if (skipMergeProdBranch || noBackMergeHotfix ) {
310+ refToMerge = hotfixBranchName ;
311+ } else if (!skipTag ) {
312+ refToMerge = gitFlowConfig .getVersionTagPrefix () + tagVersion ;
313+ } else {
314+ refToMerge = gitFlowConfig .getProductionBranch ();
315+ }
316+ gitMergeNoff (refToMerge , commitMessages .getHotfixFinishDevMergeMessage (), messageProperties );
303317
304318 // which version to increment
305319 GitFlowVersionInfo hotfixVersionInfo = new GitFlowVersionInfo (
0 commit comments