User: rednesto Date: 28 Sep 24 21:44 Revision: c8460ddd34b87ba42cddb0d0174564febe90af00 Summary: Add SemanticVersion special parsing case for Minecraft snapshots TeamCity URL: https://ci.mcdev.io/viewModification.html?tab=vcsModificationFiles&modId=9729&personal=false Index: src/main/kotlin/util/SemanticVersion.kt =================================================================== --- src/main/kotlin/util/SemanticVersion.kt (revision c98bc7a39b474fcf90363bd159570b252379b8e0) +++ src/main/kotlin/util/SemanticVersion.kt (revision c8460ddd34b87ba42cddb0d0174564febe90af00) @@ -151,6 +151,24 @@ } } + // Regular Minecraft snapshot versions e.g. 24w39a + fun parseMinecraftSnapshot(value: String): SemanticVersion? { + if (value.length != 6 || value[2] != 'w' || !value[5].isLetter()) { + return null + } + + val shortYear = value.substring(0, 2).toIntOrNull() ?: return null + val week = value.substring(3, 5).toIntOrNull() ?: return null + + val subParts = listOf(ReleasePart(week, week.toString()), TextPart(value[5].toString())) + val mainPart = PreReleasePart(shortYear, 'w', subParts, value) + return SemanticVersion( + listOf(mainPart), + ) + } + + parseMinecraftSnapshot(value)?.let { return it } + val decodedValue = value.split('+').joinToString("+") { URLDecoder.decode(it, Charsets.UTF_8) } val mainPartAndMetadata = decodedValue.split("+", limit = 2) val mainPart = mainPartAndMetadata[0]