Igor Demin 8 months ago
parent
commit
654f32f5a6
  1. 19
      tools/changelog.main.kts
  2. 1
      tools/commit-to-pr-mapping.txt

19
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 <firstCommit> <lastCommit>")
val lastCommit = args.getOrNull(1) ?: error("Please call this way: kotlin changelog.main.kts <firstCommit> <lastCommit>")
val token = args.getOrNull(2)
if (token == null) {
println("To increase the rate limit, specify token: kotlin changelog.main.kts <firstCommit> <lastCommit> 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 <reified T> 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 <reified T> request(
fun <T> 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

1
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

Loading…
Cancel
Save