257257</details>
258258` . trim ( ) ;
259259
260- // Check if the new comment is different from the previous comment
261- // We normalize by removing URLs that might change
262- const normalize = ( text : string ) => text . replace ( / \( h t t p s : \/ \/ g i t h u b . c o m [ ^ ] * \. m d \) / g , "" ) . trim ( ) ;
263-
264- const changes = ! previous_comment || normalize ( previous_comment ) !== normalize ( new_comment ) ;
265-
260+ const normalize = ( text : string ) =>
261+ text . replace ( / \( h t t p s : \/ \/ g i t h u b . c o m [ ^ ] * \. m d \) / g , "" ) . trim ( ) ;
262+
263+ const changes =
264+ ! previous_comment || normalize ( previous_comment ) !== normalize ( new_comment ) ;
265+
266266 if ( ! changes && previous_comment ) {
267- console . log ( `[create_changeset_comment] No changes detected, skipping comment update` ) ;
267+ console . log (
268+ `[create_changeset_comment] No changes detected, skipping comment update`
269+ ) ;
268270 }
269-
271+
270272 return {
271273 pr_comment_content : new_comment ,
272274 changes,
@@ -310,7 +312,8 @@ export function check_for_manual_selection_and_approval(
310312 checkbox_checked : boolean ;
311313 should_toggle_label ?: boolean ;
312314} {
313- if ( ! md_src ) return { manual_package_selection : false , checkbox_checked : false } ;
315+ if ( ! md_src )
316+ return { manual_package_selection : false , checkbox_checked : false } ;
314317
315318 const new_ast = md_parser . parse ( md_src ) ;
316319
@@ -342,7 +345,6 @@ export function check_for_manual_selection_and_approval(
342345 } ) ;
343346 }
344347
345- // Find the approval checkbox
346348 const approved_node : ListItem | undefined = find ( new_ast , ( node ) => {
347349 return (
348350 node . type === "listItem" &&
@@ -351,38 +353,38 @@ export function check_for_manual_selection_and_approval(
351353 //@ts -ignore
352354 ( node as ListItem ) ?. children [ 0 ] ,
353355 ( inner_node ) =>
354- ( inner_node as Text ) ?. value
355- ?. trim ( )
356- ?. includes ( "approve" ) &&
357- ( inner_node as Text ) ?. value
358- ?. trim ( )
359- ?. includes ( "checkbox" )
356+ ( inner_node as Text ) ?. value ?. trim ( ) ?. includes ( "approve" ) &&
357+ ( inner_node as Text ) ?. value ?. trim ( ) ?. includes ( "checkbox" )
360358 )
361359 ) ;
362360 } ) as ListItem | undefined ;
363361
364362 const checkbox_checked = ! ! approved_node ?. checked ;
365-
363+
366364 // Determine if we should toggle the label
367365 // We should toggle if:
368366 // 1. The comment was edited by a human (not gradio-pr-bot)
369367 // 2. The checkbox state doesn't match the label state
370368 let should_toggle_label = false ;
371-
372- if ( wasEdited && editor && editor !== 'gradio-pr-bot' ) {
373- // Human edit - check if checkbox state differs from label state
374- if ( has_approved_label !== undefined && checkbox_checked !== has_approved_label ) {
369+
370+ if ( wasEdited && editor && editor !== "gradio-pr-bot" ) {
371+ if (
372+ has_approved_label !== undefined &&
373+ checkbox_checked !== has_approved_label
374+ ) {
375375 should_toggle_label = true ;
376- console . log ( `[check_for_manual_selection_and_approval] Label toggle needed: checkbox=${ checkbox_checked } , label=${ has_approved_label } ` ) ;
376+ console . log (
377+ `[check_for_manual_selection_and_approval] Label toggle needed: checkbox=${ checkbox_checked } , label=${ has_approved_label } `
378+ ) ;
377379 }
378380 }
379-
381+
380382 console . log ( `[check_for_manual_selection_and_approval] States:` , {
381383 manual_package_selection : ! ! manual_node ?. checked ,
382384 checkbox_checked,
383385 has_approved_label,
384386 should_toggle_label,
385- editor
387+ editor,
386388 } ) ;
387389
388390 return {
@@ -556,33 +558,38 @@ export function get_client(token: string, owner: string, repo: string) {
556558 return url ;
557559 }
558560 } ,
559-
561+
560562 async get_or_create_label ( label_name : string ) : Promise < string | null > {
561563 try {
562- const { repository : { label } } = await octokit . graphql < Record < string , any > > (
563- GQL_GET_LABEL ,
564- { owner, name : repo , label_name }
565- ) ;
564+ const {
565+ repository : { label } ,
566+ } = await octokit . graphql < Record < string , any > > ( GQL_GET_LABEL , {
567+ owner,
568+ name : repo ,
569+ label_name,
570+ } ) ;
566571 return label ?. id || null ;
567572 } catch ( error ) {
568- console . log ( `Label "${ label_name } " not found, will need to be created manually` ) ;
573+ console . log (
574+ `Label "${ label_name } " not found, will need to be created manually`
575+ ) ;
569576 return null ;
570577 }
571578 } ,
572-
579+
573580 async add_label ( pr_id : string , label_id : string ) {
574581 console . log ( `Adding label with ID ${ label_id } to PR` ) ;
575582 await octokit . graphql ( GQL_ADD_LABELS , {
576583 pr_id,
577- label_ids : [ label_id ]
584+ label_ids : [ label_id ] ,
578585 } ) ;
579586 } ,
580-
587+
581588 async remove_label ( pr_id : string , label_id : string ) {
582589 console . log ( `Removing label with ID ${ label_id } from PR` ) ;
583590 await octokit . graphql ( GQL_REMOVE_LABELS , {
584591 pr_id,
585- label_ids : [ label_id ]
592+ label_ids : [ label_id ] ,
586593 } ) ;
587594 } ,
588595 } ;
0 commit comments