//checkout the branch to merge just so we can run any extensions that need to be on this branch
checkoutTopicBranch(prefixedBranchName,extension);
//first merge master
MergeProcessExtensionWrapper masterExtension = new MergeProcessExtensionWrapper(extension.beforeMasterCheckout(), extension.afterMasterCheckout(), extension.beforeMasterMerge(), extension.afterMasterMerge());
masterResult = doMerge(prefixedBranchName, gfConfig.getMaster(), masterExtension);
//now, tag master
if (!noTag && masterResult.getMergeStatus().isSuccessful())
{
doTag(gfConfig.getMaster(), message, masterResult,extension);
}
//IMPORTANT: we need to back-merge master into develop so that git describe works properly
MergeProcessExtensionWrapper developExtension = new MergeProcessExtensionWrapper(extension.beforeDevelopCheckout(), extension.afterDevelopCheckout(), extension.beforeDevelopMerge(), extension.afterDevelopMerge());
developResult = doMerge(gfConfig.getMaster(), gfConfig.getDevelop(), developExtension);
boolean mergeSuccess = checkMergeResults(masterResult, developResult);
if (mergeSuccess)
{
doPushIfNeeded(extension, !noTag, gfConfig.getDevelop(), gfConfig.getMaster(), prefixedBranchName);
}
if (mergeSuccess)
{
cleanupBranchesIfNeeded(gfConfig.getDevelop(), prefixedBranchName);
}
//Backmerge to release branch if needed
if(releaseBranchExists())
{
String releaseBranchName = getReleaseBranchName();
MergeProcessExtensionWrapper releaseExtension = new MergeProcessExtensionWrapper(extension.beforeReleaseCheckout(), extension.afterReleaseCheckout(), extension.beforeReleaseMerge(), extension.afterReleaseMerge());
releaseResult = doMerge(gfConfig.getMaster(), releaseBranchName, releaseExtension);
boolean releaseMergeSuccess = checkMergeResults(releaseResult);