diff --git a/lib/prepare_release.js b/lib/prepare_release.js index c34a5e80..9be5cb54 100644 --- a/lib/prepare_release.js +++ b/lib/prepare_release.js @@ -363,8 +363,14 @@ export default class ReleasePreparation extends Session { try { runSync('git', ['rev-parse', tagName]); } catch { - this.cli.startSpinner(`Error parsing git ref ${tagName}, attempting fetching it as a tag`); - runSync('git', ['fetch', this.upstream, 'tag', '-n', tagName]); + this.cli.error(`Error parsing git ref ${tagName}`); + this.cli.startSpinner('Attempting fetching it as a tag\n'); + try { + runSync('git', ['fetch', this.upstream, 'tag', '-n', tagName]); + } catch (e) { + this.cli.error(`${e.message}\nRun: git remote update`); + process.exit(1); + } this.cli.stopSpinner(`Tag fetched: ${tagName}`); } try { @@ -765,7 +771,7 @@ export default class ReleasePreparation extends Session { } async prepareLocalBranch() { - const { cli } = this; + const { cli, isSecurityRelease } = this; if (this.newVersion) { // If the CLI asked for a specific version: const newVersion = semver.parse(this.newVersion); @@ -789,11 +795,19 @@ export default class ReleasePreparation extends Session { // Otherwise, we need to figure out what's the next version number for the // release line of the branch that's currently checked out. const currentBranch = this.getCurrentBranch(); - const match = /^v(\d+)\.x-staging$/.exec(currentBranch); + // In security releases vN.x branch is the base + let regex = /^v(\d+)\.x-staging$/; + let targetBranch = 'vN.x-staging'; + if (isSecurityRelease) { + regex = /^v(\d+)\.x$/; + targetBranch = 'vN.x'; + } + + const match = regex.exec(currentBranch); if (!match) { cli.warn(`Cannot prepare a release from ${currentBranch - }. Switch to a staging branch before proceeding.`); + }. Switch to a ${targetBranch} branch before proceeding.`); return; } this.stagingBranch = currentBranch;