(changelog)
| 171 | } |
| 172 | |
| 173 | function parseChangelog(changelog) { |
| 174 | // Split the changelog into lines but also keep the line numbers. |
| 175 | const lines = changelog.split('\n').map((text, index) => ({ text, index })); |
| 176 | |
| 177 | // Remove duplicate empty lines. |
| 178 | for (var i = 0; i < lines.length; i++) { |
| 179 | if (lines[i].text == "" && (i == 0 || lines[i - 1].text == "")) { |
| 180 | lines.splice(i, 1); |
| 181 | i--; |
| 182 | } |
| 183 | } |
| 184 | |
| 185 | var ctx = { |
| 186 | lines, |
| 187 | lineIndex: 0, |
| 188 | versions: [] |
| 189 | }; |
| 190 | |
| 191 | while (ctx.lineIndex < ctx.lines.length) { |
| 192 | const versionBlock = readVersionBlock(ctx); |
| 193 | ctx.versions.push(versionBlock); |
| 194 | } |
| 195 | |
| 196 | return ctx.versions; |
| 197 | } |
| 198 | |
| 199 | function referenceSort(a, b) { |
| 200 | // Extract the number from the reference |
no test coverage detected