Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
runStep({ title: 'Preparing a staging branch' }, () => {
const { getStagingBranchName, remote } = config;
const stagingBranch = getStagingBranchName({ nextVersion, releaseType });
if (hasLocalBranch(stagingBranch, dir)) {
print(error(`The branch "${stagingBranch}" already exists locally.`));
print('Delete the local branch and try again. For example,');
print(` $ git branch -d ${stagingBranch}`);
exitProcess(1);
}
if (hasRemoteBranch(remote, stagingBranch, dir)) {
print(error(`The branch "${stagingBranch}" already exists remotely.`));
print('Delete the remote branch and try again. For example,');
print(` $ git push ${remote} :${stagingBranch}`);
exitProcess(1);
}
return { stagingBranch };
});
const {
mergeStrategy,
formatPullRequestTitle,
formatPullRequestMessage,
publishCommand,
pullRequestReviewer,
remote,
monorepo,
} = config;
const destinationBranch = getDestinationBranchName({
baseBranch,
mergeStrategy,
});
if (
baseBranch !== destinationBranch &&
!hasRemoteBranch(remote, destinationBranch, dir)
) {
print(warning('You want to release using a dedicated release branch.'));
print(
warning(
`The name of the branch is \`${destinationBranch}\`, but you don't have it yet.`
)
);
print(warning('Create that branch pointing to a latest stable commit.'));
print(warning('After that, try again.'));
print('');
print(warning('Rolling back for now...'));
run({ command: `git checkout ${baseBranch}`, dir, dryRun });
run({ command: `git branch -D ${stagingBranch}`, dir, dryRun });
exitProcess(0);
}
const { url: repoURL, owner, name: repo } = getRepoInfo(remote, dir);