@@ -363,8 +363,14 @@ export default class ReleasePreparation extends Session {
363363 try {
364364 runSync ( 'git' , [ 'rev-parse' , tagName ] ) ;
365365 } catch {
366- this . cli . startSpinner ( `Error parsing git ref ${ tagName } , attempting fetching it as a tag` ) ;
367- runSync ( 'git' , [ 'fetch' , this . upstream , 'tag' , '-n' , tagName ] ) ;
366+ this . cli . error ( `Error parsing git ref ${ tagName } ` ) ;
367+ this . cli . startSpinner ( 'Attempting fetching it as a tag\n' ) ;
368+ try {
369+ runSync ( 'git' , [ 'fetch' , this . upstream , 'tag' , '-n' , tagName ] ) ;
370+ } catch ( e ) {
371+ this . cli . error ( `${ e . message } \nRun: git remote update` ) ;
372+ process . exit ( 1 ) ;
373+ }
368374 this . cli . stopSpinner ( `Tag fetched: ${ tagName } ` ) ;
369375 }
370376 try {
@@ -765,7 +771,7 @@ export default class ReleasePreparation extends Session {
765771 }
766772
767773 async prepareLocalBranch ( ) {
768- const { cli } = this ;
774+ const { cli, isSecurityRelease } = this ;
769775 if ( this . newVersion ) {
770776 // If the CLI asked for a specific version:
771777 const newVersion = semver . parse ( this . newVersion ) ;
@@ -789,11 +795,19 @@ export default class ReleasePreparation extends Session {
789795 // Otherwise, we need to figure out what's the next version number for the
790796 // release line of the branch that's currently checked out.
791797 const currentBranch = this . getCurrentBranch ( ) ;
792- const match = / ^ v ( \d + ) \. x - s t a g i n g $ / . exec ( currentBranch ) ;
793798
799+ // In security releases vN.x branch is the base
800+ let regex = / ^ v ( \d + ) \. x - s t a g i n g $ / ;
801+ let targetBranch = 'vN.x-staging' ;
802+ if ( isSecurityRelease ) {
803+ regex = / ^ v ( \d + ) \. x $ / ;
804+ targetBranch = 'vN.x' ;
805+ }
806+
807+ const match = regex . exec ( currentBranch ) ;
794808 if ( ! match ) {
795809 cli . warn ( `Cannot prepare a release from ${ currentBranch
796- } . Switch to a staging branch before proceeding.`) ;
810+ } . Switch to a ${ targetBranch } branch before proceeding.`) ;
797811 return ;
798812 }
799813 this . stagingBranch = currentBranch ;
0 commit comments