Merge pull request #916 from iflytek/fix/triage-heading-levels

fix(triage): support level-2 issue headings
This commit is contained in:
XiaoSeS 2026-10-08 17:38:57 +08:00 • committed by GitHub
commit 8a0d82f30a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 68 additions and 1 deletions

View file

@ -27,7 +27,7 @@ import { buildMaintainerHandoffBrief } from "./issue-handoff-brief.ts";
export function parseIssueBody(body: string | null): ParsedIssueBody {
const sections: Record<string, string> = {};
const rawBody = body ?? "";
const headingMatches = [...rawBody.matchAll(/^###\s+(.+)$/gm)];
const headingMatches = [...rawBody.matchAll(/^#{2,3}\s+(.+)$/gm)];
for (let index = 0; index < headingMatches.length; index += 1) {
const current = headingMatches[index];

View file

@ -0,0 +1,67 @@
import type { GitHubIssue } from "./github.ts";
import { analyzeIssue, parseIssueBody } from "./issue-triage-lib.ts";
function assertEquals(actual: unknown, expected: unknown) {
const actualJson = JSON.stringify(actual);
const expectedJson = JSON.stringify(expected);
if (actualJson !== expectedJson) {
throw new Error(`Expected ${expectedJson}, received ${actualJson}`);
}
}
function featureIssue(body: string): GitHubIssue {
return {
number: 1,
title: "[Feature] Improve issue triage",
body,
state: "open",
labels: [{ name: "enhancement" }],
comments: 0,
created_at: "2026-10-01T00:00:00Z",
updated_at: "2026-10-01T00:00:00Z",
user: { login: "contributor" },
html_url: "https://github.com/iflytek/skillhub/issues/1",
};
}
Deno.test("level-2 headings satisfy required feature sections", () => {
const result = analyzeIssue(
featureIssue(`## Problem
Filled issues are marked as incomplete.
## Proposed solution
Recognize level-2 headings during triage.`),
[],
new Date("2026-10-01T00:00:00Z"),
);
assertEquals(result.missingFields, []);
assertEquals(result.route === "needs-info", false);
});
Deno.test("level-3 Issue Form headings keep their existing behavior", () => {
const parsed = parseIssueBody(`### Problem
Filled issues are marked as incomplete.
### Proposed Solution
Recognize headings generated by Issue Forms.`);
assertEquals(parsed.sections, {
problem: "Filled issues are marked as incomplete.",
"proposed solution": "Recognize headings generated by Issue Forms.",
});
});
Deno.test("mixed level-2 and level-3 headings are parsed together", () => {
const parsed = parseIssueBody(`## Problem
Filled issues are marked as incomplete.
### Proposed Solution
Recognize both supported heading levels.`);
assertEquals(parsed.sections, {
problem: "Filled issues are marked as incomplete.",
"proposed solution": "Recognize both supported heading levels.",
});
});