Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions src/check-gitignore.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,27 @@ describe("patchGitignore", () => {
rmSync(dir, { recursive: true, force: true });
}
});

it("ignores .kit contents via .kit/* and re-includes the curated shared tier", async () => {
const dir = tmpRepo();
try {
await patchGitignore(dir);
const text = readFileSync(join(dir, ".gitignore"), "utf-8");
// Must use the descendable `.kit/*` form, never the wholesale `.kit/`
// (which would make the `!.kit/shared/` negation a no-op).
const lines = text.split("\n").map((l) => l.split("#")[0].trim());
assert.ok(lines.includes(".kit/*"), "expected .kit/* contents-ignore");
assert.ok(!lines.includes(".kit/"), "must not emit wholesale .kit/");
assert.ok(lines.includes("!.kit/shared/"), "expected shared re-include");
// Order matters: the negation must come AFTER .kit/*.
assert.ok(
lines.indexOf("!.kit/shared/") > lines.indexOf(".kit/*"),
"negation must follow .kit/*",
);
} finally {
rmSync(dir, { recursive: true, force: true });
}
});
});

describe("findCommittedSensitive", () => {
Expand Down
8 changes: 7 additions & 1 deletion src/check-gitignore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,13 @@ const REQUIRED_PATTERNS: RequiredEntry[] = [
{ pattern: ".env.local", reason: "local secrets materialized by kit secrets", aliases: [".env*"] },
{ pattern: ".env.*.local", reason: "per-env local secrets", aliases: [".env*"] },
{ pattern: "node_modules", reason: "dependency tree", aliases: ["node_modules/"] },
{ pattern: ".kit/", reason: "kit local state (elevation, env, runtime)", aliases: [".kit", ".kit/*"] },
// Ignore kit's local-state CONTENTS via `.kit/*` (not the wholesale `.kit/`):
// git won't descend into a wholesale-excluded dir, so a later `!.kit/shared/`
// negation cannot re-include the curated, committed-by-design shared tier
// (.kit/shared/memory.jsonl). `.kit/*` ignores the contents while leaving the
// dir descendable, so the negation below works.
{ pattern: ".kit/*", reason: "kit local state (elevation, env, runtime)", aliases: [".kit", ".kit/", ".kit/*"] },
{ pattern: "!.kit/shared/", reason: "keep curated shared memory tracked (committed by design)", aliases: ["!.kit/shared", "!.kit/shared/**"] },
{ pattern: ".kit-audit.jsonl", reason: "audit log can contain secret labels + paths" },
{ pattern: "*.pem", reason: "PEM keys / certs" },
{ pattern: "*.key", reason: "private keys" },
Expand Down
3 changes: 2 additions & 1 deletion src/status.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ describe("kit status", () => {
[
".env*",
"node_modules",
".kit/",
".kit/*",
"!.kit/shared/",
".kit-audit.jsonl",
"*.pem",
"*.key",
Expand Down
Loading