Skip to content

Commit ebf54aa

Browse files
committed
fix(maint): preserve whitespace in gate fingerprints
1 parent 359c54f commit ebf54aa

2 files changed

Lines changed: 40 additions & 2 deletions

File tree

scripts/pr-lib/gates.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ run_hosted_prepare_gates() {
2929
}
3030

3131
compute_pr_patch_id() {
32-
git diff --binary "$1" "$2" | git patch-id --stable | awk 'NR == 1 { print $1 }'
32+
git diff --binary "$1" "$2" | git patch-id --verbatim | awk 'NR == 1 { print $1 }'
3333
}
3434

3535
pin_worktree_bundled_plugins_dir() {

test/scripts/pr-prepare-gates.test.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,44 @@ describe("lease-retry gate stamp refresh", () => {
334334
});
335335

336336
describe("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

Comments
 (0)