* Parse the changelog to extract PR numbers for a specific version
(changelogPath, version)
| 53 | * Parse the changelog to extract PR numbers for a specific version |
| 54 | */ |
| 55 | function getPRsForVersion(changelogPath, version) { |
| 56 | const changelog = fs.readFileSync(changelogPath, "utf-8"); |
| 57 | const lines = changelog.split("\n"); |
| 58 | |
| 59 | const prNumbers = []; |
| 60 | let inTargetVersion = false; |
| 61 | |
| 62 | for (const line of lines) { |
| 63 | // Check if we're entering the target version section |
| 64 | const versionMatch = line.match(/^## \[([^\]]+)\]/); |
| 65 | if (versionMatch) { |
| 66 | if (versionMatch[1] === version) { |
| 67 | inTargetVersion = true; |
| 68 | continue; |
| 69 | } else if (inTargetVersion) { |
| 70 | // We've moved past the target version, stop parsing |
| 71 | break; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | // If we're in the target version section, extract PR numbers |
| 76 | if (inTargetVersion) { |
| 77 | const prMatches = line.matchAll(/\[#(\d+)\]\([^)]+\)/g); |
| 78 | for (const match of prMatches) { |
| 79 | prNumbers.push(parseInt(match[1], 10)); |
| 80 | } |
| 81 | } |
| 82 | } |
| 83 | |
| 84 | return [...new Set(prNumbers)]; // Remove duplicates |
| 85 | } |
| 86 | |
| 87 | /** |
| 88 | * Find Linear issues that have attachments linking to the given GitHub PRs |