Skip to content

Commit

Permalink
feat(release): add skipBranchDiff option (#724)
Browse files Browse the repository at this point in the history
Adds an option that allows skipping the initial `branch-diff` check step in the
release command. This should be very convenient for releasers that are updating
a current work in progress proposal, particularly helping avoid hitting GitHub
API rate limits.
  • Loading branch information
ruyadorno committed Sep 23, 2023
1 parent 6d68c99 commit d103f28
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 22 deletions.
4 changes: 4 additions & 0 deletions components/git/release.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ const releaseOptions = {
describe: 'Labels separated by "," to filter security PRs',
type: 'string'
},
skipBranchDiff: {
describe: 'Skips the initial branch-diff check when preparing releases',
type: 'boolean'
},
startLTS: {
describe: 'Mark the release as the transition from Current to LTS',
type: 'boolean'
Expand Down
5 changes: 5 additions & 0 deletions docs/git-node.md
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,11 @@ git node release --prepare --startLTS
git node release --prepare --security --filterLabel 18.x 18.20.1
```

```
# Skip the branch-diff initial check (useful when updating ongoing proposals)
git node release --prepare 1.2.3 --skipBranchDiff
```

## `git node sync`

Demo: https://asciinema.org/a/221230
Expand Down
48 changes: 26 additions & 22 deletions lib/prepare_release.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export default class ReleasePreparation {
this.isSecurityRelease = argv.security;
this.isLTS = false;
this.isLTSTransition = argv.startLTS;
this.runBranchDiff = !argv.skipBranchDiff;
this.ltsCodename = '';
this.date = '';
this.config = getMergedConfig(this.dir);
Expand Down Expand Up @@ -202,31 +203,34 @@ export default class ReleasePreparation {
this.config.repo = 'node-private';
return this.prepareSecurity();
}
// TODO: UPDATE re-use
// Check the branch diff to determine if the releaser
// wants to backport any more commits before proceeding.
cli.startSpinner('Fetching branch-diff');
const raw = this.getBranchDiff({
onlyNotableChanges: false,
comparisonBranch: newVersion
});

const diff = raw.split('*');
cli.stopSpinner('Got branch diff');
if (this.runBranchDiff) {
// TODO: UPDATE re-use
// Check the branch diff to determine if the releaser
// wants to backport any more commits before proceeding.
cli.startSpinner('Fetching branch-diff');
const raw = this.getBranchDiff({
onlyNotableChanges: false,
comparisonBranch: newVersion
});

const outstandingCommits = diff.length - 1;
if (outstandingCommits !== 0) {
const staging = `v${semver.major(newVersion)}.x-staging`;
const proceed = await cli.prompt(
`There are ${outstandingCommits} commits that may be ` +
`backported to ${staging} - do you still want to proceed?`,
{ defaultAnswer: false });
const diff = raw.split('*');
cli.stopSpinner('Got branch diff');

if (!proceed) {
const seeDiff = await cli.prompt(
'Do you want to see the branch diff?');
if (seeDiff) cli.log(raw);
return;
const outstandingCommits = diff.length - 1;
if (outstandingCommits !== 0) {
const staging = `v${semver.major(newVersion)}.x-staging`;
const proceed = await cli.prompt(
`There are ${outstandingCommits} commits that may be ` +
`backported to ${staging} - do you still want to proceed?`,
{ defaultAnswer: false });

if (!proceed) {
const seeDiff = await cli.prompt(
'Do you want to see the branch diff?');
if (seeDiff) cli.log(raw);
return;
}
}
}

Expand Down

0 comments on commit d103f28

Please sign in to comment.