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
7 changes: 6 additions & 1 deletion review-enrichment/src/analysis-context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,12 @@ function categorizeFile(path: string): FileCategory {
) {
return { path, extension, category: "config" };
}
if ([".md", ".mdx", ".rst", ".txt"].includes(extension)) {
// Long-form doc spellings (.markdown/.adoc/.asciidoc) are docs too, matching the canonical
// DOCS_EXTENSIONS set in src/signals/path-matchers.ts and rag.ts's DOC_EXT_RE; without them a
// NOTES.markdown or guide.adoc file fell through to the source category.
if (
[".md", ".markdown", ".mdx", ".rst", ".adoc", ".asciidoc", ".txt"].includes(extension)
) {
return { path, extension, category: "docs" };
}
if (
Expand Down
25 changes: 25 additions & 0 deletions review-enrichment/test/analysis-context.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,31 @@ test("createAnalysisContext classifies Zstandard archives as assets for schedule
assert.deepEqual(plan.skipped.map((item) => [item.name, item.skipReason]), []);
});

test("createAnalysisContext classifies long-form doc extensions as docs", () => {
const context = createAnalysisContext({
repoFullName: "JSONbored/gittensory",
prNumber: 3264,
files: [
{ path: "GUIDE.markdown", patch: "@@ -1,0 +1,1 @@\n+# guide" },
{ path: "docs/manual.adoc", patch: "@@ -1,0 +1,1 @@\n+= Manual" },
{ path: "docs/spec.asciidoc", patch: "@@ -1,0 +1,1 @@\n+= Spec" },
{ path: "README.ADOC", patch: "@@ -1,0 +1,1 @@\n+= Readme" },
{ path: "src/index.ts", patch: "@@ -1,0 +1,1 @@\n+export {};" },
],
});

assert.deepEqual(
context.fileCategories.map((file) => [file.path, file.category]),
[
["GUIDE.markdown", "docs"],
["docs/manual.adoc", "docs"],
["docs/spec.asciidoc", "docs"],
["README.ADOC", "docs"],
["src/index.ts", "source"],
],
);
});

test("createAnalysisContext classifies lockfile paths case-insensitively", () => {
const context = createAnalysisContext({
repoFullName: "JSONbored/gittensory",
Expand Down
Loading