test(perf): stub pre-commit helpers in hook integration test

This commit is contained in:
Peter Steinberger
2026-03-02 12:27:37 +00:00
parent 5fed91e624
commit f94d6fb1f1

View File

@@ -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.