feat(triage): add CHANGELOG parser for delivery detection

This commit is contained in:
diegosouzapw
2026-05-19 02:31:47 -03:00
parent 6b05fb7906
commit 22400a4f86
2 changed files with 75 additions and 0 deletions

View File

@@ -0,0 +1,33 @@
/**
* Delivery detection: PR merged + CHANGELOG + git log, with confidence grading.
*/
const VERSION_HEADER_RE = /^##\s+\[?(\d+\.\d+\.\d+)\]?/;
export function parseChangelog(text, issueNumber) {
if (typeof text !== "string") return null;
const needle = `#${issueNumber}`;
const lines = text.split("\n");
let currentSection = null;
let currentVersion = null;
for (const line of lines) {
const headerMatch = line.match(VERSION_HEADER_RE);
if (headerMatch) {
currentSection = line.trim();
currentVersion = headerMatch[1];
continue;
}
if (line.includes(needle) && currentSection) {
const match = line.match(/\(#\d+\)/);
if (match && match[0] === `(${needle})`) {
return {
section: currentSection,
version: currentVersion,
line: line.trim(),
};
}
}
}
return null;
}