diff --git a/test/git-hooks-pre-commit.test.ts b/test/git-hooks-pre-commit.test.ts index 88252e57297..de61a1abd7c 100644 --- a/test/git-hooks-pre-commit.test.ts +++ b/test/git-hooks-pre-commit.test.ts @@ -13,20 +13,25 @@ describe("git-hooks/pre-commit (integration)", () => { const dir = mkdtempSync(path.join(os.tmpdir(), "openclaw-pre-commit-")); run(dir, "git", ["init", "-q"]); - // Copy the hook + helpers so the test exercises real on-disk wiring. + // Use the real hook script and lightweight helper stubs. mkdirSync(path.join(dir, "git-hooks"), { recursive: true }); mkdirSync(path.join(dir, "scripts", "pre-commit"), { recursive: true }); symlinkSync( path.join(process.cwd(), "git-hooks", "pre-commit"), path.join(dir, "git-hooks", "pre-commit"), ); - symlinkSync( - path.join(process.cwd(), "scripts", "pre-commit", "run-node-tool.sh"), + writeFileSync( path.join(dir, "scripts", "pre-commit", "run-node-tool.sh"), + "#!/usr/bin/env bash\nexit 0\n", + { + encoding: "utf8", + mode: 0o755, + }, ); - symlinkSync( - path.join(process.cwd(), "scripts", "pre-commit", "filter-staged-files.mjs"), + writeFileSync( path.join(dir, "scripts", "pre-commit", "filter-staged-files.mjs"), + "process.exit(0);\n", + "utf8", ); // Create an untracked file that should NOT be staged by the hook.