@@ -147,23 +147,31 @@ export default class ReleasePromotion extends Session {
147147 cli . warn ( `Aborting release promotion for version ${ version } ` ) ;
148148 throw new Error ( 'Aborted' ) ;
149149 }
150- await this . cherryPickToDefaultBranch ( ) ;
150+ const appliedCleanly = await this . cherryPickToDefaultBranch ( ) ;
151151
152- // Update `node_version.h`
153- await forceRunAsync ( 'git' , [ 'checkout' , 'HEAD' , '--' , 'src/node_version.h' ] ,
152+ // Ensure `node_version.h`'s `NODE_VERSION_IS_RELEASE` bit is not updated
153+ await forceRunAsync ( 'git' ,
154+ [ 'checkout' , appliedCleanly ? 'HEAD^' : 'HEAD' , '--' , 'src/node_version.h' ] ,
154155 { ignoreFailure : false } ) ;
155156
156- // There will be remaining cherry-pick conflicts the Releaser will
157- // need to resolve, so confirm they've been resolved before
158- // proceeding with next steps.
159- cli . separator ( ) ;
160- cli . info ( 'Resolve the conflicts and commit the result' ) ;
161- cli . separator ( ) ;
162- const didResolveConflicts = await cli . prompt (
163- 'Finished resolving cherry-pick conflicts?' , { defaultAnswer : true } ) ;
164- if ( ! didResolveConflicts ) {
165- cli . warn ( `Aborting release promotion for version ${ version } ` ) ;
166- throw new Error ( 'Aborted' ) ;
157+ if ( appliedCleanly ) {
158+ // There were no conflicts, we have to amend the commit to revert the
159+ // `node_version.h` changes.
160+ await forceRunAsync ( 'git' , [ 'commit' , ...this . gpgSign , '--amend' , '--no-edit' , '-n' ] ,
161+ { ignoreFailure : false } ) ;
162+ } else {
163+ // There will be remaining cherry-pick conflicts the Releaser will
164+ // need to resolve, so confirm they've been resolved before
165+ // proceeding with next steps.
166+ cli . separator ( ) ;
167+ cli . info ( 'Resolve the conflicts and commit the result' ) ;
168+ cli . separator ( ) ;
169+ const didResolveConflicts = await cli . prompt (
170+ 'Finished resolving cherry-pick conflicts?' , { defaultAnswer : true } ) ;
171+ if ( ! didResolveConflicts ) {
172+ cli . warn ( `Aborting release promotion for version ${ version } ` ) ;
173+ throw new Error ( 'Aborted' ) ;
174+ }
167175 }
168176
169177 if ( existsSync ( '.git/CHERRY_PICK_HEAD' ) ) {
@@ -488,8 +496,14 @@ export default class ReleasePromotion extends Session {
488496
489497 await this . tryResetBranch ( ) ;
490498
491- // There will be conflicts, we do not want to treat this as a failure.
492- await forceRunAsync ( 'git' , [ 'cherry-pick' , ...this . gpgSign , releaseCommitSha ] ,
493- { ignoreFailure : true } ) ;
499+ // There might be conflicts, we do not want to treat this as a hard failure,
500+ // but we want to retain that information.
501+ try {
502+ await forceRunAsync ( 'git' , [ 'cherry-pick' , ...this . gpgSign , releaseCommitSha ] ,
503+ { ignoreFailure : false } ) ;
504+ return true ;
505+ } catch {
506+ return false ;
507+ }
494508 }
495509}
0 commit comments