From 654f32f5a6348bc0682b19ebd70cb3565a1c4fc8 Mon Sep 17 00:00:00 2001 From: Igor Demin Date: Wed, 13 Mar 2024 15:54:58 +0100 Subject: [PATCH] Script --- tools/changelog.main.kts | 19 +++++++++++++++---- tools/commit-to-pr-mapping.txt | 1 + 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/tools/changelog.main.kts b/tools/changelog.main.kts index 250e98bf50..19540cc538 100644 --- a/tools/changelog.main.kts +++ b/tools/changelog.main.kts @@ -31,6 +31,11 @@ import java.util.concurrent.TimeUnit val firstCommit = args.getOrNull(0) ?: error("Please call this way: kotlin changelog.main.kts ") val lastCommit = args.getOrNull(1) ?: error("Please call this way: kotlin changelog.main.kts ") +val token = args.getOrNull(2) + +if (token == null) { + println("To increase the rate limit, specify token: kotlin changelog.main.kts TOKEN") +} // commits that don't have a link to a PR (a link should be something like " (#454)") val commitToPRLinkMapping = File("commit-to-pr-mapping.txt").readLines().associate { @@ -230,7 +235,12 @@ fun String.execCommand(workingDir: File = File(".")): String? { inline fun request( url: String ): T = exponentialRetry { - URL(url).openStream().use { + val connection = URL(url).openConnection() + connection.setRequestProperty("User-Agent", "Compose-Multiplatform-Script") + if (token != null) { + connection.setRequestProperty("Authorization", "Bearer $token") + } + connection.getInputStream().use { Gson().fromJson( it.bufferedReader(), T::class.java @@ -240,14 +250,15 @@ inline fun request( fun exponentialRetry(block: () -> T): T { val exception = IOException() - val retriesSeconds = listOf(60, 300, 1200) - for (retriesSecond in retriesSeconds) { + val retriesMinutes = listOf(1, 5, 15, 30, 60) + for (retriesMinute in retriesMinutes) { try { return block() } catch (e: IOException) { e.printStackTrace() exception.addSuppressed(e) - Thread.sleep(retriesSecond.toLong()) + println("Retry in $retriesMinute minutes") + Thread.sleep(retriesMinute.toLong() * 60 * 1000) } } throw exception diff --git a/tools/commit-to-pr-mapping.txt b/tools/commit-to-pr-mapping.txt index 269a8846f8..121b273554 100644 --- a/tools/commit-to-pr-mapping.txt +++ b/tools/commit-to-pr-mapping.txt @@ -1 +1,2 @@ 4e948e4bc3a9bd0ee364a6f8ddf5d982394e53c8 https://github.com/JetBrains/compose-multiplatform/pull/4333 +1603734af1def23861391630ffcbd058350e7652 https://github.com/JetBrains/compose-multiplatform-core/pull/1113