Skip to content

armgit / Ix

Public Imported from GitHub
0

Understand any codebase instantly. System intelligence for codebases, built for humans and AI.

fix: drop the trailing slash from the remaining artifact ignore rules (#580)

KageBinary59933d5eb002
diff --git a/.gitignore b/.gitignore
index 03006ae1..76d4178c 100644
--- a/.gitignore
+++ b/.gitignore
@@ -20,10 +20,15 @@ target/
# ix-cli/node_modules in #545 and stayed tracked until #567. Without the slash
# the rule matches the entry whatever its type, at any depth, which also makes
# the two package-specific lines that used to sit here redundant.
+#
+# The same applies to the build outputs below. A symlinked `dist` is how a git
+# worktree borrows a build from the main clone -- the same practice that
+# produced the node_modules symlink -- so a directory-only rule there leaves
+# exactly the defect above open under a different name.
node_modules
-core-ingestion/dist/
-ix-cli/dist/
-ix-cli/coverage/
+core-ingestion/dist
+ix-cli/dist
+ix-cli/coverage
# watch-dedup.test.ts used to build a throwaway CLI into
# ix-cli/.watch-child-runtime-*; it now builds inside node_modules/.cache,
diff --git a/ix-cli/src/cli/__tests__/watch-dedup.test.ts b/ix-cli/src/cli/__tests__/watch-dedup.test.ts
index b66a6c01..fd9d7b9a 100644
--- a/ix-cli/src/cli/__tests__/watch-dedup.test.ts
+++ b/ix-cli/src/cli/__tests__/watch-dedup.test.ts
@@ -183,12 +183,29 @@ describe("canonical watch refresh", () => {
// committable `ix-cli/node_modules` symlink of #545 with it. A path that
// does not exist is not a directory as far as git is concerned, so only a
// rule without the trailing slash matches it.
- const nonDirectory = path.join(packageRoot, "__ix_ignore_probe__", "node_modules");
- expect(fs.existsSync(nonDirectory), "probe path must not exist").toBe(false);
- expect(
- sourceOf(explain(nonDirectory)),
- "the node_modules ignore rule is directory-only again; a symlink or file named node_modules is committable (Ix#545)",
- ).toBe(".gitignore");
+ //
+ // Every artifact rule, not only node_modules: a symlinked `dist` is how a
+ // worktree borrows a build from the main clone, which is the same practice
+ // that produced the committed node_modules symlink. Probing one rule would
+ // let the other three regress silently, which is how they were left
+ // directory-only when node_modules was fixed.
+ const repoRootOf = (p: string): string => path.resolve(packageRoot, "..", p);
+ const probes: [string, string][] = [
+ [path.join(packageRoot, "__ix_ignore_probe__", "node_modules"), "node_modules"],
+ [repoRootOf("ix-cli/dist"), "ix-cli/dist"],
+ [repoRootOf("ix-cli/coverage"), "ix-cli/coverage"],
+ [repoRootOf("core-ingestion/dist"), "core-ingestion/dist"],
+ ];
+ for (const [probe, rule] of probes) {
+ // An existing directory matches a trailing-slash rule too, so a probe
+ // that happens to be a real build directory proves nothing. Ask about a
+ // sibling path that cannot exist instead.
+ const target = fs.existsSync(probe) ? path.join(probe, "__ix_ignore_probe__") : probe;
+ expect(
+ sourceOf(explain(target)),
+ `the '${rule}' ignore rule is directory-only again; a symlink or file with that name is committable (Ix#545)`,
+ ).toBe(".gitignore");
+ }
} else {
expect(path.relative(packageRoot, cacheRoot).split(path.sep)[0]).toBe("node_modules");
}