

























@@ -103,6 +103,30 @@ describe("git-hooks/pre-commit (integration)", () => {
103103expect(run(dir, "git", ["diff", "--cached", "--name-only"])).toBe("tracked.txt");
104104});
105105106+it("does not re-add staged paths that are ignored by the current .gitignore", () => {
107+const dir = makeTempRepoRoot(tempDirs, "openclaw-pre-commit-ignored-staged-");
108+run(dir, "git", ["init", "-q", "--initial-branch=main"]);
109+110+const fakeBinDir = installPreCommitFixture(dir);
111+mkdirSync(path.join(dir, ".agents", "skills", "discord-clawd"), { recursive: true });
112+writeFileSync(path.join(dir, ".gitignore"), ".agents/skills/discord-clawd/\n", "utf8");
113+writeFileSync(
114+path.join(dir, ".agents", "skills", "discord-clawd", "SKILL.md"),
115+"# Discord Clawd\n",
116+"utf8",
117+);
118+119+run(dir, "git", ["add", "--", ".gitignore"]);
120+run(dir, "git", ["add", "-f", "--", ".agents/skills/discord-clawd/SKILL.md"]);
121+122+run(dir, "bash", ["git-hooks/pre-commit"], {
123+PATH: `${fakeBinDir}:${process.env.PATH ?? ""}`,
124+});
125+126+const staged = run(dir, "git", ["diff", "--cached", "--name-only"]).split("\n").filter(Boolean);
127+expect(staged).toEqual([".agents/skills/discord-clawd/SKILL.md", ".gitignore"]);
128+});
129+106130it("ignores FAST_COMMIT because the hook is already formatting-only", () => {
107131const dir = makeTempRepoRoot(tempDirs, "openclaw-pre-commit-fast-");
108132run(dir, "git", ["init", "-q", "--initial-branch=main"]);
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。