@@ -508,7 +508,7 @@ export function verifiedTerminalStatusReceipt(
508508 : commandCommentIds . length === 0 &&
509509 ! hasCommandAckMarker ( comment . body ) &&
510510 ( options . statusCommentId === null || completionCommentId === options . statusCommentId )
511- ? legacyCommandCommentId ( comment . body , options . marker )
511+ ? legacyCommandCommentId ( comment . body , options . marker , completionCommentId )
512512 : null ;
513513 return commandCommentId === null ? null : { commandCommentId, completionCommentId } ;
514514 }
@@ -555,8 +555,12 @@ function hasCommandAckMarker(body: JsonValue) {
555555 return / < ! - - \s * c l a w s w e e p e r - c o m m a n d - a c k : [ ^ > ] * - - > / . test ( String ( body ?? "" ) ) ;
556556}
557557
558- function legacyCommandCommentId ( body : JsonValue , statusMarker : string ) {
559- const status = / ^ < ! - - \s * c l a w s w e e p e r - c o m m a n d - s t a t u s : \d + : ( [ ^ : \s > ] + ) : ( [ ^ : \s > ] + ) \s * - - > $ / . exec (
558+ function legacyCommandCommentId (
559+ body : JsonValue ,
560+ statusMarker : string ,
561+ completionCommentId : number ,
562+ ) {
563+ const status = / ^ < ! - - \s * c l a w s w e e p e r - c o m m a n d - s t a t u s : ( \d + ) : ( [ ^ : \s > ] + ) : ( [ ^ : \s > ] + ) \s * - - > $ / . exec (
560564 statusMarker ,
561565 ) ;
562566 if ( ! status ) return null ;
@@ -565,11 +569,30 @@ function legacyCommandCommentId(body: JsonValue, statusMarker: string) {
565569 / < ! - - \s * c l a w s w e e p e r - c o m m a n d : ( \d + ) : (?: [ ^ > ] * : ) ? ( [ ^ : \s > ] + ) : ( [ ^ : \s > ] + ) \s * - - > / g,
566570 ) ,
567571 ) ;
568- if ( commands . length !== 1 || commands [ 0 ] ! [ 2 ] !== status [ 1 ] || commands [ 0 ] ! [ 3 ] !== status [ 2 ] ) {
572+ if ( commands . length === 1 && commands [ 0 ] ! [ 2 ] === status [ 2 ] && commands [ 0 ] ! [ 3 ] === status [ 3 ] ) {
573+ const commandCommentId = Number ( commands [ 0 ] ! [ 1 ] ) ;
574+ return Number . isSafeInteger ( commandCommentId ) && commandCommentId > 0 ? commandCommentId : null ;
575+ }
576+ if ( commands . length !== 0 ) return null ;
577+ const commandMarkers = Array . from (
578+ String ( body ?? "" ) . matchAll ( / < ! - - \s * c l a w s w e e p e r - c o m m a n d : [ ^ > ] + - - > / g) ,
579+ ) ;
580+ if ( commandMarkers . length !== 1 ) return null ;
581+ const syntheticCommands = Array . from (
582+ String ( body ?? "" ) . matchAll (
583+ / < ! - - \s * c l a w s w e e p e r - c o m m a n d : r e p a i r - l o o p - l a b e l - s w e e p : ( a u t o f i x | a u t o m e r g e ) : ( \d + ) : ( a u t o f i x | a u t o m e r g e ) : ( [ ^ : \s > ] + ) \s * - - > / g,
584+ ) ,
585+ ) ;
586+ if (
587+ syntheticCommands . length !== 1 ||
588+ syntheticCommands [ 0 ] ! [ 1 ] !== status [ 2 ] ||
589+ syntheticCommands [ 0 ] ! [ 2 ] !== status [ 1 ] ||
590+ syntheticCommands [ 0 ] ! [ 3 ] !== status [ 2 ] ||
591+ syntheticCommands [ 0 ] ! [ 4 ] !== status [ 3 ]
592+ ) {
569593 return null ;
570594 }
571- const commandCommentId = Number ( commands [ 0 ] ! [ 1 ] ) ;
572- return Number . isSafeInteger ( commandCommentId ) && commandCommentId > 0 ? commandCommentId : null ;
595+ return completionCommentId ;
573596}
574597
575598function commandStatusMarkersFromBody ( body : JsonValue ) {
0 commit comments