Igor Demin 6 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 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 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)") // 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 { 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( inline fun <reified T> request(
url: String url: String
): T = exponentialRetry { ): 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( Gson().fromJson(
it.bufferedReader(), it.bufferedReader(),
T::class.java T::class.java
@ -240,14 +250,15 @@ inline fun <reified T> request(
fun <T> exponentialRetry(block: () -> T): T { fun <T> exponentialRetry(block: () -> T): T {
val exception = IOException() val exception = IOException()
val retriesSeconds = listOf(60, 300, 1200) val retriesMinutes = listOf(1, 5, 15, 30, 60)
for (retriesSecond in retriesSeconds) { for (retriesMinute in retriesMinutes) {
try { try {
return block() return block()
} catch (e: IOException) { } catch (e: IOException) {
e.printStackTrace() e.printStackTrace()
exception.addSuppressed(e) exception.addSuppressed(e)
Thread.sleep(retriesSecond.toLong()) println("Retry in $retriesMinute minutes")
Thread.sleep(retriesMinute.toLong() * 60 * 1000)
} }
} }
throw exception throw exception

1
tools/commit-to-pr-mapping.txt

@ -1 +1,2 @@
4e948e4bc3a9bd0ee364a6f8ddf5d982394e53c8 https://github.com/JetBrains/compose-multiplatform/pull/4333 4e948e4bc3a9bd0ee364a6f8ddf5d982394e53c8 https://github.com/JetBrains/compose-multiplatform/pull/4333
1603734af1def23861391630ffcbd058350e7652 https://github.com/JetBrains/compose-multiplatform-core/pull/1113

Loading…
Cancel
Save