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-")); const dir = mkdtempSync(path.join(os.tmpdir(), "openclaw-pre-commit-"));
run(dir, "git", ["init", "-q"]); 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, "git-hooks"), { recursive: true });
mkdirSync(path.join(dir, "scripts", "pre-commit"), { recursive: true }); mkdirSync(path.join(dir, "scripts", "pre-commit"), { recursive: true });
symlinkSync( symlinkSync(
path.join(process.cwd(), "git-hooks", "pre-commit"), path.join(process.cwd(), "git-hooks", "pre-commit"),
path.join(dir, "git-hooks", "pre-commit"), path.join(dir, "git-hooks", "pre-commit"),
); );
symlinkSync( writeFileSync(
path.join(process.cwd(), "scripts", "pre-commit", "run-node-tool.sh"),
path.join(dir, "scripts", "pre-commit", "run-node-tool.sh"), path.join(dir, "scripts", "pre-commit", "run-node-tool.sh"),
"#!/usr/bin/env bash\nexit 0\n",
{
encoding: "utf8",
mode: 0o755,
},
); );
symlinkSync( writeFileSync(
path.join(process.cwd(), "scripts", "pre-commit", "filter-staged-files.mjs"),
path.join(dir, "scripts", "pre-commit", "filter-staged-files.mjs"), 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. // Create an untracked file that should NOT be staged by the hook.