From 149c8eaba3e6582ed0654f78d63914a2d41eb98e Mon Sep 17 00:00:00 2001 From: pneumorea-ai Date: Sun, 20 Sep 2026 14:43:10 +0800 Subject: [PATCH] test(redact): cover chunked large push diffs --- test/redact-prepush-hook.test.ts | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/redact-prepush-hook.test.ts b/test/redact-prepush-hook.test.ts index e71c58c875c..a98daf79e60 100644 --- a/test/redact-prepush-hook.test.ts +++ b/test/redact-prepush-hook.test.ts @@ -107,6 +107,42 @@ describe("pre-push hook gating", () => { expect(code).toBe(0); expect(stderr).toContain("MEDIUM"); }); + + test("clean pushed diff larger than the engine cap is scanned in chunks", () => { + const base = git(["rev-parse", "HEAD"]); + fs.writeFileSync(path.join(repo, "large-a.txt"), "clean-a ".repeat(90_000)); + fs.writeFileSync(path.join(repo, "large-b.txt"), "clean-b ".repeat(90_000)); + git(["add", "large-a.txt", "large-b.txt"]); + git(["commit", "-q", "-m", "large clean diff"]); + const head = git(["rev-parse", "HEAD"]); + + const { code, stderr } = runHook( + `refs/heads/main ${head} refs/heads/main ${base}\n`, + ); + + expect(code).toBe(0); + expect(stderr).not.toContain("engine.input_too_large"); + }); + + test("credential after the first chunk of a large pushed diff still blocks", () => { + const base = git(["rev-parse", "HEAD"]); + fs.writeFileSync(path.join(repo, "large-a.txt"), "clean-a ".repeat(90_000)); + fs.writeFileSync( + path.join(repo, "large-b.txt"), + "clean-b ".repeat(90_000) + "\n" + FAKE_AWS_KEY + "\n", + ); + git(["add", "large-a.txt", "large-b.txt"]); + git(["commit", "-q", "-m", "large diff with credential"]); + const head = git(["rev-parse", "HEAD"]); + + const { code, stderr } = runHook( + `refs/heads/main ${head} refs/heads/main ${base}\n`, + ); + + expect(code).toBe(1); + expect(stderr).toContain("aws.access_key"); + expect(stderr).not.toContain("engine.input_too_large"); + }); }); describe("diff direction + special refs", () => {