























@@ -64,11 +64,6 @@ describe("git-hooks/pre-commit (integration)", () => {
64646565// Use the real hook script and lightweight helper stubs.
6666const fakeBinDir = installPreCommitFixture(dir);
67-// The hook can end with `pnpm check:changed --staged`, but this fixture is only
68-// exercising staged-file handling.
69-// Stub pnpm too so Windows CI does not invoke a real package-manager command in the temp repo.
70-writeExecutable(fakeBinDir, "pnpm", "#!/usr/bin/env bash\nexit 0\n");
71-7267// Create an untracked file that should NOT be staged by the hook.
7368writeFileSync(path.join(dir, "secret.txt"), "do-not-stage\n", "utf8");
7469@@ -85,8 +80,8 @@ describe("git-hooks/pre-commit (integration)", () => {
8580expect(staged).toEqual(["--all"]);
8681});
878288-it("runs changed-scope check for non-doc staged changes", () => {
89-const dir = makeTempRepoRoot(tempDirs, "openclaw-pre-commit-check-changed-");
83+it("does not run the changed-scope check for non-doc staged changes", () => {
84+const dir = makeTempRepoRoot(tempDirs, "openclaw-pre-commit-no-check-changed-");
9085run(dir, "git", ["init", "-q", "--initial-branch=main"]);
91869287const fakeBinDir = installPreCommitFixture(dir);
@@ -95,7 +90,7 @@ describe("git-hooks/pre-commit (integration)", () => {
9590writeExecutable(
9691fakeBinDir,
9792"pnpm",
98-"#!/usr/bin/env bash\nprintf '%s\\n' \"$*\" > pnpm-args.txt\n",
93+"#!/usr/bin/env bash\necho 'pnpm should not run from pre-commit' >&2\nexit 99\n",
9994);
1009510196writeFileSync(path.join(dir, "tracked.txt"), "hello\n", "utf8");
@@ -105,11 +100,11 @@ describe("git-hooks/pre-commit (integration)", () => {
105100PATH: `${fakeBinDir}:${process.env.PATH ?? ""}`,
106101});
107102108-expect(run(dir, "cat", ["pnpm-args.txt"])).toBe("check:changed --staged");
103+expect(run(dir, "git", ["diff", "--cached", "--name-only"])).toBe("tracked.txt");
109104});
110105111-it("skips changed-scope check when FAST_COMMIT is enabled", () => {
112-const dir = makeTempRepoRoot(tempDirs, "openclaw-pre-commit-yolo-");
106+it("ignores FAST_COMMIT because the hook is already formatting-only", () => {
107+const dir = makeTempRepoRoot(tempDirs, "openclaw-pre-commit-fast-");
113108run(dir, "git", ["init", "-q", "--initial-branch=main"]);
114109115110const fakeBinDir = installPreCommitFixture(dir);
@@ -125,13 +120,11 @@ describe("git-hooks/pre-commit (integration)", () => {
125120writeFileSync(path.join(dir, "tracked.txt"), "hello\n", "utf8");
126121run(dir, "git", ["add", "--", "tracked.txt"]);
127122128-const output = run(dir, "bash", ["git-hooks/pre-commit"], {
123+run(dir, "bash", ["git-hooks/pre-commit"], {
129124PATH: `${fakeBinDir}:${process.env.PATH ?? ""}`,
130125FAST_COMMIT: "1",
131126});
132127133-expect(output).toContain(
134-"FAST_COMMIT enabled: skipping changed-scope check in pre-commit hook.",
135-);
128+expect(run(dir, "git", ["diff", "--cached", "--name-only"])).toBe("tracked.txt");
136129});
137130});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。