修复无法解析类似 "26.1 Snapshot 1" 的版本号的问题 (#5002)

This commit is contained in:
Glavo
2025-12-18 21:09:07 +08:00
committed by GitHub
parent d45d994307
commit 25c9ef0f27
2 changed files with 5 additions and 0 deletions

View File

@@ -337,6 +337,10 @@ public abstract sealed class GameVersionNumber implements Comparable<GameVersion
} else if (suffix.startsWith("-snapshot-")) { } else if (suffix.startsWith("-snapshot-")) {
releaseType = ReleaseType.SNAPSHOT; releaseType = ReleaseType.SNAPSHOT;
eaVersion = VersionNumber.asVersion(suffix.substring("-snapshot-".length())); eaVersion = VersionNumber.asVersion(suffix.substring("-snapshot-".length()));
} else if (suffix.startsWith(" Snapshot ")) {
needNormalize = true;
releaseType = ReleaseType.SNAPSHOT;
eaVersion = VersionNumber.asVersion(suffix.substring(" Snapshot ".length()));
} else if (suffix.startsWith("-pre")) { } else if (suffix.startsWith("-pre")) {
releaseType = ReleaseType.PRE_RELEASE; releaseType = ReleaseType.PRE_RELEASE;
eaVersion = VersionNumber.asVersion(suffix.substring("-pre".length())); eaVersion = VersionNumber.asVersion(suffix.substring("-pre".length()));

View File

@@ -432,6 +432,7 @@ public final class GameVersionNumberTest {
assertNormalized(version, version); assertNormalized(version, version);
} }
assertNormalized("26.1-snapshot-1", "26.1 Snapshot 1");
assertNormalized("1.21.11-pre3", "1.21.11 Pre-Release 3"); assertNormalized("1.21.11-pre3", "1.21.11 Pre-Release 3");
assertNormalized("1.21.11-pre3_unobfuscated", "1.21.11 Pre-Release 3 Unobfuscated"); assertNormalized("1.21.11-pre3_unobfuscated", "1.21.11 Pre-Release 3 Unobfuscated");
assertNormalized("1.21.11-pre3_unobfuscated", "1.21.11-pre3 Unobfuscated"); assertNormalized("1.21.11-pre3_unobfuscated", "1.21.11-pre3 Unobfuscated");