@@ -144,23 +144,34 @@ export default class ReleasePromotion extends Session {
144
144
cli . warn ( `Aborting release promotion for version ${ version } ` ) ;
145
145
throw new Error ( 'Aborted' ) ;
146
146
}
147
- await this . cherryPickToDefaultBranch ( ) ;
148
-
149
- // Update `node_version.h`
150
- await forceRunAsync ( 'git' , [ 'checkout' , 'HEAD' , '--' , 'src/node_version.h' ] ,
151
- { ignoreFailure : false } ) ;
147
+ const appliedCleanly = await this . cherryPickToDefaultBranch ( ) ;
148
+
149
+ // Ensure `node_version.h`'s `NODE_VERSION_IS_RELEASE` bit is not updated
150
+ await forceRunAsync ( 'git' , [ 'checkout' ,
151
+ appliedCleanly
152
+ ? 'HEAD^' // In the absence of conflict, the top of the remote branch is the commit before.
153
+ : 'HEAD' , // In case of conflict, HEAD is still the top of the remove branch.
154
+ '--' , 'src/node_version.h' ] ,
155
+ { ignoreFailure : false } ) ;
152
156
153
- // There will be remaining cherry-pick conflicts the Releaser will
154
- // need to resolve, so confirm they've been resolved before
155
- // proceeding with next steps.
156
- cli . separator ( ) ;
157
- cli . info ( 'Resolve the conflicts and commit the result' ) ;
158
- cli . separator ( ) ;
159
- const didResolveConflicts = await cli . prompt (
160
- 'Finished resolving cherry-pick conflicts?' , { defaultAnswer : true } ) ;
161
- if ( ! didResolveConflicts ) {
162
- cli . warn ( `Aborting release promotion for version ${ version } ` ) ;
163
- 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
+ }
164
175
}
165
176
166
177
if ( existsSync ( '.git/CHERRY_PICK_HEAD' ) ) {
@@ -469,8 +480,14 @@ export default class ReleasePromotion extends Session {
469
480
470
481
await this . tryResetBranch ( ) ;
471
482
472
- // There will be conflicts, we do not want to treat this as a failure.
473
- await forceRunAsync ( 'git' , [ 'cherry-pick' , ...this . gpgSign , releaseCommitSha ] ,
474
- { ignoreFailure : true } ) ;
483
+ // There might be conflicts, we do not want to treat this as a hard failure,
484
+ // but we want to retain that information.
485
+ try {
486
+ await forceRunAsync ( 'git' , [ 'cherry-pick' , ...this . gpgSign , releaseCommitSha ] ,
487
+ { ignoreFailure : false } ) ;
488
+ return true ;
489
+ } catch {
490
+ return false ;
491
+ }
475
492
}
476
493
}
0 commit comments