Skip to content

Commit

Permalink
fix(git-node): do not assume release commit will conflict (#871)
Browse files Browse the repository at this point in the history
  • Loading branch information
aduh95 authored Nov 19, 2024
1 parent 82527ad commit ec6c6cb
Showing 1 changed file with 36 additions and 19 deletions.
55 changes: 36 additions & 19 deletions lib/promote_release.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,23 +144,34 @@ export default class ReleasePromotion extends Session {
cli.warn(`Aborting release promotion for version ${version}`);
throw new Error('Aborted');
}
await this.cherryPickToDefaultBranch();

// Update `node_version.h`
await forceRunAsync('git', ['checkout', 'HEAD', '--', 'src/node_version.h'],
{ ignoreFailure: false });
const appliedCleanly = await this.cherryPickToDefaultBranch();

// Ensure `node_version.h`'s `NODE_VERSION_IS_RELEASE` bit is not updated
await forceRunAsync('git', ['checkout',
appliedCleanly
? 'HEAD^' // In the absence of conflict, the top of the remote branch is the commit before.
: 'HEAD', // In case of conflict, HEAD is still the top of the remove branch.
'--', 'src/node_version.h'],
{ ignoreFailure: false });

// There will be remaining cherry-pick conflicts the Releaser will
// need to resolve, so confirm they've been resolved before
// proceeding with next steps.
cli.separator();
cli.info('Resolve the conflicts and commit the result');
cli.separator();
const didResolveConflicts = await cli.prompt(
'Finished resolving cherry-pick conflicts?', { defaultAnswer: true });
if (!didResolveConflicts) {
cli.warn(`Aborting release promotion for version ${version}`);
throw new Error('Aborted');
if (appliedCleanly) {
// There were no conflicts, we have to amend the commit to revert the
// `node_version.h` changes.
await forceRunAsync('git', ['commit', ...this.gpgSign, '--amend', '--no-edit', '-n'],
{ ignoreFailure: false });
} else {
// There will be remaining cherry-pick conflicts the Releaser will
// need to resolve, so confirm they've been resolved before
// proceeding with next steps.
cli.separator();
cli.info('Resolve the conflicts and commit the result');
cli.separator();
const didResolveConflicts = await cli.prompt(
'Finished resolving cherry-pick conflicts?', { defaultAnswer: true });
if (!didResolveConflicts) {
cli.warn(`Aborting release promotion for version ${version}`);
throw new Error('Aborted');
}
}

if (existsSync('.git/CHERRY_PICK_HEAD')) {
Expand Down Expand Up @@ -469,8 +480,14 @@ export default class ReleasePromotion extends Session {

await this.tryResetBranch();

// There will be conflicts, we do not want to treat this as a failure.
await forceRunAsync('git', ['cherry-pick', ...this.gpgSign, releaseCommitSha],
{ ignoreFailure: true });
// There might be conflicts, we do not want to treat this as a hard failure,
// but we want to retain that information.
try {
await forceRunAsync('git', ['cherry-pick', ...this.gpgSign, releaseCommitSha],
{ ignoreFailure: false });
return true;
} catch {
return false;
}
}
}

0 comments on commit ec6c6cb

Please sign in to comment.