fix: getMilestoneInfo() returns wrong version after milestone completion (#768)

Strip <details> blocks (shipped milestones) before matching, and extract
both version and name from the same ## heading for consistency.
This commit is contained in:
Hnturk
2026-02-27 11:17:36 +03:00
parent f9fc2a3f33
commit 38c19466ae
2 changed files with 87 additions and 3 deletions

View File

@@ -379,11 +379,21 @@ function generateSlugInternal(text) {
function getMilestoneInfo(cwd) {
try {
const roadmap = fs.readFileSync(path.join(cwd, '.planning', 'ROADMAP.md'), 'utf-8');
const versionMatch = roadmap.match(/v(\d+\.\d+)/);
const nameMatch = roadmap.match(/## .*v\d+\.\d+[:\s]+([^\n(]+)/);
// Strip <details>...</details> blocks so shipped milestones don't interfere
const cleaned = roadmap.replace(/<details>[\s\S]*?<\/details>/gi, '');
// Extract version and name from the same ## heading for consistency
const headingMatch = cleaned.match(/## .*v(\d+\.\d+)[:\s]+([^\n(]+)/);
if (headingMatch) {
return {
version: 'v' + headingMatch[1],
name: headingMatch[2].trim(),
};
}
// Fallback: try bare version match
const versionMatch = cleaned.match(/v(\d+\.\d+)/);
return {
version: versionMatch ? versionMatch[0] : 'v1.0',
name: nameMatch ? nameMatch[1].trim() : 'milestone',
name: 'milestone',
};
} catch {
return { version: 'v1.0', name: 'milestone' };