@@ -334,6 +334,44 @@ describe("lease-retry gate stamp refresh", () => {
334334} ) ;
335335
336336describe ( "prepare gate stamp transitions" , ( ) => {
337+ it ( "preserves whitespace in the rebase patch fingerprint" , ( ) => {
338+ const { repoDir, headSha : baseSha } = makeRetryRepo ( ) ;
339+ writeFileSync ( join ( repoDir , "config.yml" ) , "root:\n child: value\n" ) ;
340+ spawnSync ( "git" , [ "add" , "config.yml" ] , { cwd : repoDir } ) ;
341+ spawnSync (
342+ "git" ,
343+ [ "-c" , "user.name=t" , "-c" , "[email protected] " , "commit" , "-qm" , "two spaces" ] , 344+ { cwd : repoDir } ,
345+ ) ;
346+ const twoSpaceSha = spawnSync ( "git" , [ "rev-parse" , "HEAD" ] , {
347+ cwd : repoDir ,
348+ encoding : "utf8" ,
349+ } ) . stdout . trim ( ) ;
350+ writeFileSync ( join ( repoDir , "config.yml" ) , "root:\n child: value\n" ) ;
351+ spawnSync ( "git" , [ "add" , "config.yml" ] , { cwd : repoDir } ) ;
352+ spawnSync (
353+ "git" ,
354+ [ "-c" , "user.name=t" , "-c" , "[email protected] " , "commit" , "-qm" , "four spaces" ] , 355+ { cwd : repoDir } ,
356+ ) ;
357+ const fourSpaceSha = spawnSync ( "git" , [ "rev-parse" , "HEAD" ] , {
358+ cwd : repoDir ,
359+ encoding : "utf8" ,
360+ } ) . stdout . trim ( ) ;
361+
362+ const result = runGatesBash (
363+ [
364+ `compute_pr_patch_id ${ baseSha } ${ twoSpaceSha } ` ,
365+ `compute_pr_patch_id ${ baseSha } ${ fourSpaceSha } ` ,
366+ ] . join ( "\n" ) ,
367+ { cwd : repoDir } ,
368+ ) ;
369+ expect ( result . status ) . toBe ( 0 ) ;
370+ const patchIds = result . stdout . trim ( ) . split ( "\n" ) ;
371+ expect ( patchIds ) . toHaveLength ( 2 ) ;
372+ expect ( patchIds [ 0 ] ) . not . toBe ( patchIds [ 1 ] ) ;
373+ } ) ;
374+
337375 it ( "uses the hosted pre-sync SHA only when its tree matches the local prep head" , ( ) => {
338376 const { repoDir, headSha } = makeRetryRepo ( ) ;
339377 const tree = spawnSync ( "git" , [ "rev-parse" , "HEAD^{tree}" ] , {
@@ -461,7 +499,7 @@ describe("prepare gate stamp transitions", () => {
461499 "bash" ,
462500 [
463501 "-c" ,
464- "git diff --binary refs/remotes/origin/main HEAD | git patch-id --stable | awk 'NR == 1 { print $1 }'" ,
502+ "git diff --binary refs/remotes/origin/main HEAD | git patch-id --verbatim | awk 'NR == 1 { print $1 }'" ,
465503 ] ,
466504 { cwd : repoDir , encoding : "utf8" } ,
467505 ) . stdout . trim ( ) ;
0 commit comments