(unreleasedLines: string[])
| 55 | } |
| 56 | |
| 57 | function parseChangelog(unreleasedLines: string[]): ParsedChangelog { |
| 58 | const importantChanges: ChangelogEntry[] = []; |
| 59 | const otherChanges: ChangelogEntry[] = []; |
| 60 | const internalChanges: ChangelogEntry[] = []; |
| 61 | const changelogPRs = new Set<string>(); |
| 62 | let contributorsLine = ''; |
| 63 | |
| 64 | let currentEntry: string[] = []; |
| 65 | let currentType: EntryType | null = null; |
| 66 | let inDetailsBlock = false; |
| 67 | let detailsContent: string[] = []; |
| 68 | |
| 69 | const addEntry = (entry: ChangelogEntry): void => { |
| 70 | if (entry.prNumber) { |
| 71 | changelogPRs.add(entry.prNumber); |
| 72 | } |
| 73 | |
| 74 | if (entry.type === 'important') { |
| 75 | importantChanges.push(entry); |
| 76 | } else if (entry.type === 'internal') { |
| 77 | internalChanges.push(entry); |
| 78 | } else { |
| 79 | otherChanges.push(entry); |
| 80 | } |
| 81 | }; |
| 82 | |
| 83 | const flushCurrentEntry = (): void => { |
| 84 | if (currentEntry.length === 0 || !currentType) return; |
| 85 | |
| 86 | // Remove trailing empty lines from the entry |
| 87 | while (currentEntry.length > 0 && !currentEntry[currentEntry.length - 1]?.trim()) { |
| 88 | currentEntry.pop(); |
| 89 | } |
| 90 | |
| 91 | if (currentEntry.length === 0) return; |
| 92 | |
| 93 | const entry = createEntry(currentEntry.join('\n'), currentType); |
| 94 | addEntry(entry); |
| 95 | |
| 96 | currentEntry = []; |
| 97 | currentType = null; |
| 98 | }; |
| 99 | |
| 100 | const processDetailsContent = (): void => { |
| 101 | for (const line of detailsContent) { |
| 102 | const trimmed = line.trim(); |
| 103 | if (trimmed.startsWith('-') && trimmed.includes('(#')) { |
| 104 | const entry = createEntry(trimmed, 'internal'); |
| 105 | addEntry(entry); |
| 106 | } |
| 107 | } |
| 108 | detailsContent = []; |
| 109 | }; |
| 110 | |
| 111 | for (const line of unreleasedLines) { |
| 112 | // Skip undefined/null lines |
| 113 | if (line == null) continue; |
| 114 |
no test coverage detected