if(GitHelper.localBranchBehindRemote(flow.git(),flow.getDevelopBranchName(),flow.getReporter()))
{
reporter.errorText("hotfix-finish","local branch '" + flow.getDevelopBranchName() + "' is behind the remote branch");
reporter.flush();
throw new BranchOutOfDateException("local branch '" + flow.getDevelopBranchName() + "' is behind the remote branch");
}
}
//get the hotfix branch
List<Ref> hotfixBranches = GitHelper.listBranchesWithPrefix(flow.git(), flow.getHotfixBranchPrefix());
if (hotfixBranches.isEmpty())
{
throw new JGitFlowReleaseException("Could not find hotfix branch!");
}
//there can be only one
String rheadPrefix = Constants.R_HEADS + flow.getHotfixBranchPrefix();
Ref hotfixBranch = hotfixBranches.get(0);
hotfixLabel = hotfixBranch.getName().substring(hotfixBranch.getName().indexOf(rheadPrefix) + rheadPrefix.length());
String prefixedBranchName = flow.getHotfixBranchPrefix() + hotfixLabel;
//make sure we're on the hotfix branch
flow.git().checkout().setName(prefixedBranchName).call();
//make sure we're not behind remote
if(GitHelper.remoteBranchExists(flow.git(), prefixedBranchName, reporter))
{
if(GitHelper.localBranchBehindRemote(flow.git(),prefixedBranchName,reporter))
{
reporter.errorText("hotfix-finish","local branch '" + prefixedBranchName + "' is behind the remote branch");
reporter.flush();
throw new BranchOutOfDateException("local branch '" + prefixedBranchName + "' is behind the remote branch");
}
}
if(GitHelper.remoteBranchExists(flow.git(), flow.getMasterBranchName(), flow.getReporter()))
{
if(ctx.isPullMaster())
{
reporter.debugText("finishHotfix", "pulling master before remote behind check");
reporter.flush();
flow.git().checkout().setName(flow.getMasterBranchName()).call();
flow.git().pull().call();
flow.git().checkout().setName(prefixedBranchName).call();
}
if(GitHelper.localBranchBehindRemote(flow.git(),flow.getMasterBranchName(),flow.getReporter()))
{
reporter.errorText("hotfix-finish","local branch '" + flow.getMasterBranchName() + "' is behind the remote branch");
reporter.flush();
throw new BranchOutOfDateException("local branch '" + flow.getMasterBranchName() + "' is behind the remote branch");
}
}
//get the reactor projects for hotfix
MavenSession hotfixSession = getSessionForBranch(flow, prefixedBranchName, originalProjects, session);