@@ -193,7 +193,7 @@ fun generateChangelog() {
193
193
appendLine(" ### $subsection " )
194
194
appendLine()
195
195
subsectionEntries.forEach {
196
- appendLine(it.format() )
196
+ appendLine(it.run { " $message [# $prNumber ]( $link ) " } )
197
197
}
198
198
appendLine()
199
199
}
@@ -309,59 +309,6 @@ fun checkPr() {
309
309
*/
310
310
fun currentChangelogDate () = LocalDate .now().format(DateTimeFormatter .ofPattern(" MMMM yyyy" , Locale .ENGLISH ))
311
311
312
- /* *
313
- * Formats:
314
- * - A new approach to implementation of `platformLayers`. Now extra layers (such as Dialogs and Popups) drawing is merged into a single screen size canvas.
315
- *
316
- * to:
317
- * - [A new approach to implementation of `platformLayers`](link). Now extra layers (such as Dialogs and Popups) drawing is merged into a single screen size canvas.
318
- */
319
- fun ChangelogEntry.format (): String {
320
- return try {
321
- tryFormat()
322
- } catch (e: Exception ) {
323
- throw RuntimeException (" Formatting error of ChangelogEntry. Message:\n $message " , e)
324
- }
325
- }
326
-
327
- fun ChangelogEntry.tryFormat (): String {
328
- return if (link != null ) {
329
- val prefixRegex = " ^[-\\ s]*" // "- "
330
- val tagRegex1 = " \\ (.*\\ )\\ s*" // "(something) "
331
- val tagRegex2 = " \\ [.*\\ ]\\ s*" // "[something] "
332
- val tagRegex3 = " _.*_\\ s*" // "_something_ "
333
- val linkStartIndex = maxOf(
334
- message.endIndexOfFirstGroup(Regex (" ($prefixRegex ).*" ))?.plus(1 ) ? : 0 ,
335
- message.endIndexOfFirstGroup(Regex (" ($prefixRegex$tagRegex1 ).*" ))?.plus(1 ) ? : 0 ,
336
- message.endIndexOfFirstGroup(Regex (" ($prefixRegex$tagRegex2 ).*" ))?.plus(1 ) ? : 0 ,
337
- message.endIndexOfFirstGroup(Regex (" ($prefixRegex$tagRegex3 ).*" ))?.plus(1 ) ? : 0 ,
338
- )
339
- val linkLastIndex = message.indexOfAny(listOf (" . " , " (" ), linkStartIndex).ifNegative { message.length }
340
-
341
- val beforeLink = message.substring(0 , linkStartIndex)
342
- val inLink = message.substring(linkStartIndex, linkLastIndex).removeLinks()
343
- val afterLink = message.substring(linkLastIndex, message.length)
344
-
345
- " $beforeLink [$inLink ]($link )$afterLink "
346
- } else {
347
- message
348
- }
349
- }
350
-
351
- fun Int.ifNegative (value : () -> Int ): Int = if (this < 0 ) value() else this
352
-
353
- fun String.endIndexOfFirstGroup (regex : Regex ): Int? =
354
- regex.find(this )?.groups?.toList()?.getOrNull(1 )?.range?.endInclusive
355
-
356
- /* *
357
- * Converts:
358
- * Message (title)[some link], message
359
- *
360
- * to:
361
- * Message title, message
362
- */
363
- fun String.removeLinks (): String = replace(Regex (" \\ [([^)]*)\\ ]\\ ([^\\ ]]*\\ )" ), " $1" )
364
-
365
312
/* *
366
313
* Extract by format https://github.com/JetBrains/compose-multiplatform/blob/master/.github/PULL_REQUEST_TEMPLATE.md?plain=1
367
314
*/
@@ -421,6 +368,7 @@ fun GitHubPullEntry.extractReleaseNotes(): ReleaseNotes? {
421
368
lineFixed,
422
369
section,
423
370
subsection,
371
+ number,
424
372
htmlUrl.takeIf { isTopLevel }
425
373
)
426
374
)
@@ -448,7 +396,7 @@ fun entriesForRepo(repo: String, firstCommit: String, lastCommit: String): List<
448
396
): List <ChangelogEntry > {
449
397
return if (pullRequest != null ) {
450
398
pullRequest.extractReleaseNotes()?.entries ? :
451
- listOf (ChangelogEntry (" - ${pullRequest.title} " , null , null , pullRequest.htmlUrl))
399
+ listOf (ChangelogEntry (" - ${pullRequest.title} " , null , null , pullRequest.number, pullRequest. htmlUrl))
452
400
} else {
453
401
listOf ()
454
402
}
@@ -544,6 +492,7 @@ data class ChangelogEntry(
544
492
val message : String ,
545
493
val section : String? ,
546
494
val subsection : String? ,
495
+ val prNumber : Int ,
547
496
val link : String? ,
548
497
)
549
498
0 commit comments