Skip to content

Commit 2038e18

Browse files
committed
no-mistakes(review): Ask git about ignored docs pages from the project root
1 parent fa02453 commit 2038e18

2 files changed

Lines changed: 15 additions & 2 deletions

File tree

‎server/typescript/packages/cli/src/lib/codegen-drift.ts‎

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -300,8 +300,10 @@ export async function computeCodegenDrift(
300300
// honourGlobalExcludes: false — a personal ignore file must not change a gate.
301301
let ignored: ReadonlySet<string> = new Set<string>();
302302
if (docsDirs.has(committed) && all.size > 0) {
303-
const lookup = gitIgnored(committed, [...all].map(toPosix), { honourGlobalExcludes: false });
304-
if ("ignored" in lookup) ignored = lookup.ignored;
303+
const prefix = toPosix(relative(root, committed));
304+
const fromRoot = (rel: string): string => (prefix === "" ? toPosix(rel) : `${prefix}/${toPosix(rel)}`);
305+
const lookup = gitIgnored(root, [...all].map(fromRoot), { honourGlobalExcludes: false });
306+
if ("ignored" in lookup) ignored = new Set([...all].map(toPosix).filter((rel) => lookup.ignored.has(fromRoot(rel))));
305307
else docsIgnoreUnavailable = lookup.unavailable;
306308
const checked = [...freshFiles].filter((rel) => !ignored.has(toPosix(rel)));
307309
if (freshFiles.size > 0 && checked.length === 0) {

‎server/typescript/packages/cli/test/gen-docs-generators.test.ts‎

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -330,6 +330,17 @@ describe("meta verify --codegen checks the documentation the list declares", ()
330330
"docs/generated: the repository git-ignores every documentation page generated there, so they were not compared.",
331331
);
332332
});
333+
334+
test("on a fresh clone, where the ignored docs directory does not exist, it is still not compared", async () => {
335+
const root = project({ config: base(`["entity", docsFile()]`), ownRepo: true });
336+
writeFileSync(join(root, ".gitignore"), "docs/\n", "utf8");
337+
expect(await run(["gen", "--cwd", root])).toBe(0);
338+
rmSync(join(root, "docs"), { recursive: true, force: true });
339+
expect(await run(["verify", "--codegen", "--cwd", root])).toBe(0);
340+
expect([...out, ...err].join("\n")).toContain(
341+
"docs/generated: the repository git-ignores every documentation page generated there, so they were not compared.",
342+
);
343+
});
333344
});
334345

335346
describe("an owned docs generator is wired like any other", () => {

0 commit comments

Comments
 (0)