@@ -243,43 +243,6 @@ async function triggerGHActionWithComment(request, event, payload, message) {
243243 } ) ;
244244}
245245
246- /**
247- * @param {* } request
248- * @param {string } targetBranch
249- * @param {boolean } produceLKG
250- * @param {(s: string) => void } log
251- */
252- async function makeCherryPickPR ( request , targetBranch , produceLKG , log ) {
253- const cli = getGHClient ( ) ;
254- const pr = ( await cli . pulls . get ( { pull_number : request . issue . number , owner : "microsoft" , repo : "TypeScript" } ) ) . data ;
255- try {
256- await cli . git . getRef ( {
257- owner : "Microsoft" ,
258- repo : "TypeScript" ,
259- ref : `heads/${ targetBranch } `
260- } ) ;
261- }
262- catch ( _ ) {
263- const requestingUser = request . comment . user . login ;
264- await cli . issues . createComment ( {
265- body : `Heya @${ requestingUser } , I couldn't find the branch '${ targetBranch } ' on Microsoft/TypeScript. You may need to make it and try again.` ,
266- issue_number : pr . number ,
267- owner : "Microsoft" ,
268- repo : "TypeScript"
269- } ) ;
270- return ;
271- }
272- await makeNewBuildWithComments ( request , `task to cherry-pick this into \`${ targetBranch } \`` , 30 , log , p => ( {
273- ...p ,
274- sourceBranch : `refs/pull/${ pr . number } /head` ,
275- parameters : JSON . stringify ( {
276- ...JSON . parse ( p . parameters ) ,
277- target_branch : targetBranch ,
278- ...( produceLKG ? { PRODUCE_LKG : "true" } : { } )
279- } )
280- } ) ) ;
281- }
282-
283246/**
284247 * @typedef {Object } CommentAction
285248 * @property {(req: any, log: (s: string) => void, match: RegExpExecArray) => Promise<void> } task
@@ -415,7 +378,36 @@ const commands = (/** @type {Map<RegExp, CommentAction>} */(new Map()))
415378 } )
416379 } ;
417380 } ) ) )
418- . set ( / c h e r r y - ? p i c k (?: t h i s ) ? (?: i n ) ? t o ( \S + ) ( a n d L K G ) ? / , action ( async ( request , log , match ) => await makeCherryPickPR ( request , match [ 1 ] , ! ! match [ 2 ] , log ) ) )
381+ . set ( / c h e r r y - ? p i c k (?: t h i s ) ? (?: i n ) ? t o ( \S + ) ? / , action ( async ( request , log , match ) => {
382+ const targetBranch = match [ 1 ] ;
383+ const requestingUser = request . comment . user . login ;
384+
385+ const cli = getGHClient ( ) ;
386+ const pr = ( await cli . pulls . get ( { pull_number : request . issue . number , owner : "microsoft" , repo : "TypeScript" } ) ) . data ;
387+ try {
388+ await cli . git . getRef ( {
389+ owner : "Microsoft" ,
390+ repo : "TypeScript" ,
391+ ref : `heads/${ targetBranch } `
392+ } ) ;
393+ }
394+ catch ( _ ) {
395+ const requestingUser = request . comment . user . login ;
396+ await cli . issues . createComment ( {
397+ body : `Heya @${ requestingUser } , I couldn't find the branch '${ targetBranch } ' on Microsoft/TypeScript. You may need to make it and try again.` ,
398+ issue_number : pr . number ,
399+ owner : "Microsoft" ,
400+ repo : "TypeScript"
401+ } ) ;
402+ return ;
403+ }
404+
405+ await triggerGHActionWithComment ( request , "create-cherry-pick-pr" , {
406+ pr : request . issue . number ,
407+ target_branch : targetBranch ,
408+ requesting_user : requestingUser ,
409+ } , `cherry-pick this into \`${ targetBranch } \`` ) ;
410+ } ) )
419411 . set ( / c r e a t e r e l e a s e - ( [ \d \. ] + ) / , action ( async ( request , log , match ) => {
420412 const cli = getGHClient ( ) ;
421413 const targetBranch = `release-${ match [ 1 ] } ` ;
0 commit comments