( releases: PackageRelease[], maxLength: number, )
| 251 | } |
| 252 | |
| 253 | function truncateChangelogs( |
| 254 | releases: PackageRelease[], |
| 255 | maxLength: number, |
| 256 | ): string { |
| 257 | let lines = ["# Changelogs"]; |
| 258 | let currentLength = lines.join("\n").length; |
| 259 | let includedCount = 0; |
| 260 | |
| 261 | for (let release of releases) { |
| 262 | let changelog = "\n\n" + generatePackageChangelog(release); |
| 263 | if (currentLength + changelog.length <= maxLength) { |
| 264 | lines.push(""); |
| 265 | lines.push(generatePackageChangelog(release)); |
| 266 | currentLength += changelog.length; |
| 267 | includedCount++; |
| 268 | } else { |
| 269 | break; |
| 270 | } |
| 271 | } |
| 272 | |
| 273 | let omittedCount = releases.length - includedCount; |
| 274 | |
| 275 | if (omittedCount > 0) { |
| 276 | lines.push(""); |
| 277 | lines.push( |
| 278 | `> ⚠️ ${omittedCount} changelog${omittedCount === 1 ? "" : "s"} omitted due to size limits. See the PR diff for full details.`, |
| 279 | ); |
| 280 | } |
| 281 | |
| 282 | return lines.join("\n"); |
| 283 | } |
no test coverage detected