@@ -6,7 +6,7 @@ import TeamInfo from '../../lib/team_info.js';
66import Request from '../../lib/request.js' ;
77import { runPromise } from '../../lib/run.js' ;
88
9- export const command = 'release [prid|options ]' ;
9+ export const command = 'release [prid.. ]' ;
1010export const describe = 'Manage an in-progress release or start a new one.' ;
1111
1212const PREPARE = 'prepare' ;
@@ -34,8 +34,13 @@ const releaseOptions = {
3434 describe : 'Promote new release of Node.js' ,
3535 type : 'boolean'
3636 } ,
37+ fetchFrom : {
38+ describe : 'Remote to fetch the release proposal(s) from, if different from the one where to' +
39+ 'push the tags and commits.' ,
40+ type : 'string' ,
41+ } ,
3742 releaseDate : {
38- describe : 'Default relase date when --prepare is used. It must be YYYY-MM-DD' ,
43+ describe : 'Default release date when --prepare is used. It must be YYYY-MM-DD' ,
3944 type : 'string'
4045 } ,
4146 run : {
@@ -112,11 +117,6 @@ function release(state, argv) {
112117}
113118
114119async function main ( state , argv , cli , dir ) {
115- const prID = / ^ (?: h t t p s : \/ \/ g i t h u b \. c o m \/ n o d e j s ( - p r i v a t e ) ? \/ n o d e \1\/ p u l l \/ ) ? ( \d + ) $ / . exec ( argv . prid ) ;
116- if ( prID ) {
117- if ( prID [ 1 ] ) argv . security = true ;
118- argv . prid = Number ( prID [ 2 ] ) ;
119- }
120120 if ( state === PREPARE ) {
121121 const release = new ReleasePreparation ( argv , cli , dir ) ;
122122
@@ -160,6 +160,24 @@ async function main(state, argv, cli, dir) {
160160 cli . stopSpinner ( `${ release . username } is a Releaser` ) ;
161161 }
162162
163- return release . promote ( ) ;
163+ const releases = [ ] ;
164+ for ( const pr of argv . prid ) {
165+ const match = / ^ (?: h t t p s : \/ \/ g i t h u b \. c o m \/ ( [ ^ / ] + ) \/ ( [ ^ / ] + ) \/ p u l l \/ ) ? ( \d + ) (?: # .* ) ? $ / . exec ( pr ) ;
166+ if ( ! match ) throw new Error ( 'Invalid PR ID or URL' , { cause : pr } ) ;
167+ const [ , owner , repo , prid ] = match ;
168+
169+ if (
170+ owner &&
171+ ( owner !== release . owner || repo !== release . repo ) &&
172+ ! argv . fetchFrom
173+ ) {
174+ console . warn ( 'The configured owner/repo does not match the PR URL.' ) ;
175+ console . info ( 'You should either pass `--fetch-from` flag or check your configuration' ) ;
176+ console . info ( `E.g. --fetch-from=git@github.com:${ owner } /${ repo } .git` ) ;
177+ throw new Error ( 'You need to tell what remote use to fetch security release proposal.' ) ;
178+ }
179+ releases . push ( await release . preparePromotion ( { owner, repo, prid : Number ( prid ) } ) ) ;
180+ }
181+ return release . promote ( releases ) ;
164182 }
165183}
0 commit comments