mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-06 07:12:12 +03:00
feat(triage): add CHANGELOG parser for delivery detection
This commit is contained in:
33
scripts/features/lib/delivered.mjs
Normal file
33
scripts/features/lib/delivered.mjs
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user