Skip to content

Commit

Permalink
fix: Support LATEST_RELEASE again
Browse files Browse the repository at this point in the history
  • Loading branch information
0ffz committed May 29, 2024
1 parent 297ed8a commit b93122a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
kotlin.code.style=official
version=3.0.0-alpha.3
version=3.0.0-alpha.4
9 changes: 5 additions & 4 deletions src/main/kotlin/downloading/github/GithubDownload.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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.*
Expand Down Expand Up @@ -53,7 +54,7 @@ class GithubDownload(

override suspend fun download(): List<DownloadResult> {
val version = when (config.overrideGithubRelease) {
GithubReleaseOverride.LATEST -> "latest"
LATEST, LATEST_RELEASE -> "latest"
else -> artifact.releaseVersion
}

Expand All @@ -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}"
Expand All @@ -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)
Expand Down

0 comments on commit b93122a

Please sign in to comment.