From b93122a4483e0d29d6a97bd3b122d0858a4c4e20 Mon Sep 17 00:00:00 2001 From: Danielle Voznyy Date: Wed, 29 May 2024 13:49:45 -0400 Subject: [PATCH] fix: Support LATEST_RELEASE again --- gradle.properties | 2 +- src/main/kotlin/downloading/github/GithubDownload.kt | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/gradle.properties b/gradle.properties index 23c49cc..f7ce7e1 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ kotlin.code.style=official -version=3.0.0-alpha.3 +version=3.0.0-alpha.4 diff --git a/src/main/kotlin/downloading/github/GithubDownload.kt b/src/main/kotlin/downloading/github/GithubDownload.kt index 0e8a774..2651125 100644 --- a/src/main/kotlin/downloading/github/GithubDownload.kt +++ b/src/main/kotlin/downloading/github/GithubDownload.kt @@ -8,7 +8,8 @@ import downloading.Downloader import downloading.HttpDownload import downloading.Source import helpers.CachedRequest -import helpers.GithubReleaseOverride +import helpers.GithubReleaseOverride.LATEST +import helpers.GithubReleaseOverride.LATEST_RELEASE import helpers.MSG import io.ktor.client.* import io.ktor.client.plugins.* @@ -53,7 +54,7 @@ class GithubDownload( override suspend fun download(): List { val version = when (config.overrideGithubRelease) { - GithubReleaseOverride.LATEST -> "latest" + LATEST, LATEST_RELEASE -> "latest" else -> artifact.releaseVersion } @@ -65,7 +66,7 @@ class GithubDownload( timeout { requestTimeoutMillis = HttpTimeout.INFINITE_TIMEOUT_MS } - if (config.overrideGithubRelease == GithubReleaseOverride.LATEST) + if (config.overrideGithubRelease == LATEST) url("https://api.github.com/repos/${artifact.repo}/releases") else { val releaseURL = if (version == "latest") "latest" else "tags/${artifact.releaseVersion}" @@ -88,7 +89,7 @@ class GithubDownload( val body = response.result val release: GithubRelease = runCatching { - if (config.overrideGithubRelease == GithubReleaseOverride.LATEST) { + if (config.overrideGithubRelease == LATEST) { json.decodeFromString(ListSerializer(GithubRelease.serializer()), body) .maxBy { it.published_at } } else json.decodeFromString(GithubRelease.serializer(), body)