fix(autoversion): do not crash on single tag
All checks were successful
ci/woodpecker/push/pages Pipeline was successful
ci/woodpecker/push/gradle Pipeline was successful

This commit is contained in:
Johannes Frohnmeyer 2024-10-10 12:19:17 +02:00
parent 5583d335d1
commit 04f130951e
Signed by: Johannes
GPG Key ID: E76429612C2929F4

View File

@ -10,7 +10,7 @@ fun List<Tag>.filter(): Pair<Tag, Tag?>? {
val envName = System.getenv("CI_COMMIT_TAG")?.ifEmpty { null } val envName = System.getenv("CI_COMMIT_TAG")?.ifEmpty { null }
val current = envName?.let { v -> indexOfFirst { it.name == v } } ?: 0 val current = envName?.let { v -> indexOfFirst { it.name == v } } ?: 0
if (current == -1) throw IllegalStateException("Current tag ($envName) not found in tag list") if (current == -1) throw IllegalStateException("Current tag ($envName) not found in tag list")
if (size == current) return get(current) to null if (size == current + 1) return get(current) to null
val ver = SemanticVersion.tryParse(get(current).name) val ver = SemanticVersion.tryParse(get(current).name)
// special case: some mod projects use the format 1.0.0+forge to classify builds for different loaders // special case: some mod projects use the format 1.0.0+forge to classify builds for different loaders