1- #! / usr/ bin/ env kotlin
2-
31/*
42 * Copyright 2010-2024 JetBrains s.r.o. and Kotlin Programming Language contributors.
53 * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
64 */
75
6+ import java.lang.System
87import java.util.concurrent.TimeUnit
98import kotlin.system.exitProcess
109
11- fun getCommits (fromRevision : String , toRevision : String , path : String? ): List <Commit > {
12- val cmd = " git rev-list --format=medium $fromRevision ..$toRevision ${path ? : " . " } "
10+ fun getCommits (fromRevision : String , toRevision : String ): List <Commit > {
11+ val cmd = " git rev-list --format=medium $fromRevision ..$toRevision . "
1312 val process = ProcessBuilder (* (cmd.split(" " )).toTypedArray())
1413 .redirectOutput(ProcessBuilder .Redirect .PIPE )
1514 .redirectError(ProcessBuilder .Redirect .INHERIT )
@@ -20,7 +19,7 @@ fun getCommits(fromRevision: String, toRevision: String, path: String?): List<Co
2019 return commits.mapNotNull { commit ->
2120 val sanitizedCommit = commit.removePrefix(" commit " ).padEnd(2 , ' \n ' )
2221 val commitGroups = parseCommit.find(sanitizedCommit)?.groupValues ? : return @mapNotNull null
23- if (commitGroups? .size != 4 ) {
22+ if (commitGroups.size != 4 ) {
2423 // group 1: commit hash
2524 // group 2: commit message
2625 // group 3: title
@@ -55,7 +54,6 @@ data class Commit(
5554)
5655
5756fun commitToGitHubUrl (commit : String ) = " https://github.com/JetBrains/kotlin/commit/$commit "
58- fun changeIdToGerritUrl (changeId : String ) = " https://android-review.googlesource.com/q/$changeId "
5957fun issueToBuganizerUrl (issue : String ): String = " https://issuetracker.google.com/issues/$issue "
6058
6159fun Commit.asReleaseNote (): String {
@@ -66,33 +64,34 @@ fun Commit.asReleaseNote(): String {
6664 return " - $link $text "
6765}
6866
69- if (args.isEmpty()) {
70- println (
71- """
72- Usage: <from-tag> <to-tag> [<path>]
67+ fun main (vararg args : String ) {
68+ if (args.isEmpty()) {
69+ println (
70+ """
71+ Usage: ./gradlew composeReleaseNotes --args="<from-tag> <to-tag>:"
7372
7473 For example, to generate release notes for v2.0.0-RC2:
75- <script> v2.0.0-RC1 v2.0.0-RC2
74+ ./gradlew composeReleaseNotes --args=" v2.0.0-RC1 v2.0.0-RC2"
7675 """ .trimIndent()
77- )
78- exitProcess(1 )
79- }
76+ )
77+ exitProcess(1 )
78+ }
8079
81- val ignoreRelnotes = listOf (" n/a" )
80+ val ignoreRelnotes = listOf (" n/a" )
8281
83- val fromRevision = args[0 ]
84- val toRevision = args[1 ]
85- val path = args.getOrNull(2 )
82+ val fromRevision = args[0 ]
83+ val toRevision = args[1 ]
8684
87- val (fixes, features) = getCommits(fromRevision, toRevision, path )
88- .filter {
89- (it.relnote != null && ! ignoreRelnotes.contains(it.relnote.toLowerCase ())) ||
90- it.issues.isNotEmpty()
91- }
92- .partition { it.issues.isNotEmpty() }
85+ val (fixes, features) = getCommits(fromRevision, toRevision)
86+ .filter {
87+ (it.relnote != null && ! ignoreRelnotes.contains(it.relnote.lowercase ())) ||
88+ it.issues.isNotEmpty()
89+ }
90+ .partition { it.issues.isNotEmpty() }
9391
94- println (" ### Compose compiler" )
95- println (" #### New features" )
96- features.forEach { println (it.asReleaseNote()) }
97- println (" #### Fixes" )
98- fixes.forEach { println (it.asReleaseNote()) }
92+ println (" ### Compose compiler" )
93+ println (" #### New features" )
94+ features.forEach { println (it.asReleaseNote()) }
95+ println (" #### Fixes" )
96+ fixes.forEach { println (it.asReleaseNote()) }
97+ }
0 commit comments