mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-04 14:22:09 +03:00
34 lines
885 B
JavaScript
34 lines
885 B
JavaScript
/**
|
|
* 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;
|
|
}
|