From 8b79b4b3dee0014680ff5df93a690e70a285dd73 Mon Sep 17 00:00:00 2001 From: Peter Steinberger Date: Fri, 8 May 2026 23:38:04 +0100 Subject: [PATCH] test: reuse precommit staged line parsing --- test/git-hooks-pre-commit.test.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/test/git-hooks-pre-commit.test.ts b/test/git-hooks-pre-commit.test.ts index 2a9ec9fe53f..5777d0210de 100644 --- a/test/git-hooks-pre-commit.test.ts +++ b/test/git-hooks-pre-commit.test.ts @@ -53,6 +53,16 @@ function installPreCommitFixture(dir: string): string { return fakeBinDir; } +function splitNonEmptyLines(output: string): string[] { + const lines: string[] = []; + for (const line of output.split("\n")) { + if (line) { + lines.push(line); + } + } + return lines; +} + afterEach(() => { cleanupTempDirs(tempDirs); }); @@ -76,7 +86,7 @@ describe("git-hooks/pre-commit (integration)", () => { PATH: `${fakeBinDir}:${process.env.PATH ?? ""}`, }); - const staged = run(dir, "git", ["diff", "--cached", "--name-only"]).split("\n").filter(Boolean); + const staged = splitNonEmptyLines(run(dir, "git", ["diff", "--cached", "--name-only"])); expect(staged).toEqual(["--all"]); }); @@ -123,7 +133,7 @@ describe("git-hooks/pre-commit (integration)", () => { PATH: `${fakeBinDir}:${process.env.PATH ?? ""}`, }); - const staged = run(dir, "git", ["diff", "--cached", "--name-only"]).split("\n").filter(Boolean); + const staged = splitNonEmptyLines(run(dir, "git", ["diff", "--cached", "--name-only"])); expect(staged).toEqual([".agents/skills/discord-clawd/SKILL.md", ".gitignore"]); });