@@ -93,9 +93,10 @@ export default class ReleasePreparation extends Session {
93
93
} = this ;
94
94
95
95
// Create new proposal branch.
96
- cli . startSpinner ( `Creating new proposal branch for ${ newVersion } ` ) ;
97
- const proposalBranch = await this . createProposalBranch ( releaseBranch ) ;
98
- cli . stopSpinner ( `Created new proposal branch for ${ newVersion } ` ) ;
96
+ cli . startSpinner ( `Switching to proposal branch for ${ newVersion } ` ) ;
97
+ const { proposalBranch, resultMsg } =
98
+ await this . createProposalBranch ( releaseBranch ) ;
99
+ cli . stopSpinner ( resultMsg ) ;
99
100
100
101
const success = await this . cherryPickSecurityPRs ( filterLabels ) ;
101
102
if ( ! success ) {
@@ -201,9 +202,10 @@ export default class ReleasePreparation extends Session {
201
202
}
202
203
203
204
// Create new proposal branch.
204
- cli . startSpinner ( `Creating new proposal branch for ${ newVersion } ` ) ;
205
- await this . createProposalBranch ( ) ;
206
- cli . stopSpinner ( `Created new proposal branch for ${ newVersion } ` ) ;
205
+ cli . startSpinner ( `Switching to proposal branch for ${ newVersion } ` ) ;
206
+ const { resultMsg } =
207
+ await this . createProposalBranch ( ) ;
208
+ cli . stopSpinner ( resultMsg ) ;
207
209
208
210
if ( this . isLTSTransition ) {
209
211
// For releases transitioning into LTS, fetch the new code name.
@@ -533,13 +535,37 @@ export default class ReleasePreparation extends Session {
533
535
const { newVersion } = this ;
534
536
const proposalBranch = `v${ newVersion } -proposal` ;
535
537
536
- await runAsync ( 'git' , [
537
- 'checkout' ,
538
- '-b' ,
538
+ try {
539
+ await forceRunAsync ( 'git' , [
540
+ 'checkout' ,
541
+ '-b' ,
542
+ proposalBranch ,
543
+ base
544
+ ] , { captureStdout : true , captureStderr : true , ignoreFailure : false } ) ;
545
+ } catch ( err ) {
546
+ const branchExistsRE = / f a t a l : a b r a n c h n a m e d ' .* ' a l r e a d y e x i s t s / i;
547
+ if ( branchExistsRE . test ( err . stderr ) ) {
548
+ await runAsync ( 'git' , [
549
+ 'checkout' ,
550
+ proposalBranch
551
+ ] ) ;
552
+ await runAsync ( 'git' , [
553
+ 'reset' ,
554
+ '--hard' ,
555
+ base
556
+ ] ) ;
557
+ return {
558
+ proposalBranch,
559
+ resultMsg : `Updated proposal branch for ${ newVersion } `
560
+ } ;
561
+ } else {
562
+ throw err ;
563
+ }
564
+ }
565
+ return {
539
566
proposalBranch,
540
- base
541
- ] ) ;
542
- return proposalBranch ;
567
+ resultMsg : `Created new proposal branch for ${ newVersion } `
568
+ } ;
543
569
}
544
570
545
571
async updateNodeVersion ( ) {
0 commit comments