Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: adjust base branch when prepare --security release #889

Merged
merged 1 commit into from
Jan 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions lib/prepare_release.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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);
Expand All @@ -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;
Expand Down
Loading