@@ -270,6 +270,7 @@ const commandOptions = commander.opts<ICommanderOptions>();
270
270
name : string ,
271
271
description : string ,
272
272
action : ( repositoryOwner : string , pullRequestURL : string ) => Promise < void > ,
273
+ verbatim2ndArgument = false ,
273
274
) {
274
275
super ( name ) ;
275
276
super . argument ( "[repository-owner]" ) ;
@@ -281,9 +282,10 @@ const commandOptions = commander.opts<ICommanderOptions>();
281
282
args [ 0 ] = config . repo . owner ;
282
283
}
283
284
const [ repositoryOwner , prNumber ] = args ;
284
- const pullRequestURL = prNumber . match ( / ^ h t t p / )
285
- ? prNumber
286
- : `https://github.com/${ repositoryOwner } /${ config . repo . name } /pull/${ prNumber } ` ;
285
+ const pullRequestURL =
286
+ verbatim2ndArgument || prNumber . match ( / ^ h t t p / )
287
+ ? prNumber
288
+ : `https://github.com/${ repositoryOwner } /${ config . repo . name } /pull/${ prNumber } ` ;
287
289
return await action ( repositoryOwner , pullRequestURL ) ;
288
290
} ) ;
289
291
}
@@ -311,9 +313,7 @@ const commandOptions = commander.opts<ICommanderOptions>();
311
313
new OptionalRepoOwnerCommand (
312
314
"get-pr-commits" ,
313
315
"Get the commits for a given Pull Request" ,
314
- async ( repositoryOwner , prNumber ) => {
315
- if ( repositoryOwner === undefined ) repositoryOwner = config . repo . owner ;
316
- const pullRequestURL = `https://github.com/${ repositoryOwner } /${ config . repo . name } /pull/${ prNumber } ` ;
316
+ async ( _repositoryOwner , pullRequestURL ) => {
317
317
const prMeta = await ci . getPRMetadata ( pullRequestURL ) ;
318
318
if ( ! prMeta ) {
319
319
throw new Error ( `No metadata found for ${ pullRequestURL } ` ) ;
@@ -326,10 +326,7 @@ const commandOptions = commander.opts<ICommanderOptions>();
326
326
new OptionalRepoOwnerCommand (
327
327
"handle-pr" ,
328
328
"Handle a given Pull Request (add it to open PRs, update commit <-> message ID mapping, etc.)" ,
329
- async ( repositoryOwner , prNumber ) => {
330
- if ( repositoryOwner === undefined ) repositoryOwner = config . repo . owner ;
331
- const pullRequestURL = `https://github.com/${ repositoryOwner } /${ config . repo . name } /pull/${ prNumber } ` ;
332
-
329
+ async ( _repositoryOwner , pullRequestURL ) => {
333
330
const meta = await ci . getPRMetadata ( pullRequestURL ) ;
334
331
if ( ! meta ) {
335
332
throw new Error ( `No metadata for ${ pullRequestURL } ` ) ;
@@ -441,20 +438,21 @@ const commandOptions = commander.opts<ICommanderOptions>();
441
438
new OptionalRepoOwnerCommand (
442
439
"handle-pr-comment" ,
443
440
"Handle a comment on a Pull Request" ,
444
- async ( repositoryOwner : string | undefined , commentID : string ) => {
441
+ async ( repositoryOwner : string , commentID : string ) => {
445
442
if ( repositoryOwner === undefined ) repositoryOwner = config . repo . owner ;
446
443
await ci . handleComment ( repositoryOwner , parseInt ( commentID , 10 ) ) ;
447
444
} ,
445
+ true ,
448
446
) ,
449
447
) ;
450
448
commander . addCommand (
451
449
new OptionalRepoOwnerCommand (
452
450
"handle-pr-push" ,
453
451
"Handle a push to a Pull Request" ,
454
- async ( repositoryOwner : string | undefined , prNumber : string ) => {
455
- if ( repositoryOwner === undefined ) repositoryOwner = config . repo . owner ;
452
+ async ( repositoryOwner : string , prNumber : string ) => {
456
453
await ci . handlePush ( repositoryOwner , parseInt ( prNumber , 10 ) ) ;
457
454
} ,
455
+ true ,
458
456
) ,
459
457
) ;
460
458
commander
0 commit comments