diff --git a/src/main/groovy/com/github/winplay02/gitcraft/manifest/skyrising/SkyrisingMetadataProvider.java b/src/main/groovy/com/github/winplay02/gitcraft/manifest/skyrising/SkyrisingMetadataProvider.java index 71744c2..70839a9 100644 --- a/src/main/groovy/com/github/winplay02/gitcraft/manifest/skyrising/SkyrisingMetadataProvider.java +++ b/src/main/groovy/com/github/winplay02/gitcraft/manifest/skyrising/SkyrisingMetadataProvider.java @@ -130,17 +130,26 @@ protected boolean isExistingVersionMetadataValid(SkyrisingManifest.VersionEntry @Override public List getParentVersions(OrderedVersion mcVersion) { return this.getVersionDetails(mcVersion.launcherFriendlyVersionName()).previous().stream() + .filter(it -> !isClassicOrAlphaServer(it)) .map(this::getVersionByVersionID) - .filter(Objects::nonNull) + .peek(ver -> { + if (ver == null) { + MiscHelper.panic("One or more of the parent versions were not found for %s", mcVersion.friendlyVersion()); + } + }) .toList(); } - private static final Pattern NORMAL_SNAPSHOT_PATTERN = Pattern.compile("(^\\d\\dw\\d\\d[a-z](-\\d+)?$)|(^(1|\\d\\d).\\d+(.\\d+)?(-(pre|rc|snapshot)((-\\d+|\\d+)(-\\d+)?)?|_[a-z_\\-]+snapshot-\\d+| Pre-Release \\d+)?$)"); + private static final Pattern NORMAL_SNAPSHOT_PATTERN = Pattern.compile("(^\\d\\dw\\d\\d[a-z](-\\d+)?$)|(^(1|\\d\\d).\\d+(.\\d+)?(-(pre|rc|snapshot)((-\\d+|\\d+)(-\\d+)?)?| Pre-Release \\d+)?$)"); + + private static boolean isClassicOrAlphaServer(String versionId) { + return versionId.startsWith("server-"); + } @Override public boolean shouldExclude(OrderedVersion mcVersion) { // classic and alpha servers don't work well with the version graph right now - return mcVersion.launcherFriendlyVersionName().startsWith("server-"); + return isClassicOrAlphaServer(mcVersion.launcherFriendlyVersionName()); } @Override diff --git a/src/main/groovy/com/github/winplay02/gitcraft/manifest/vanilla/MojangLauncherMetadataProvider.java b/src/main/groovy/com/github/winplay02/gitcraft/manifest/vanilla/MojangLauncherMetadataProvider.java index 2233a4a..97ed98b 100644 --- a/src/main/groovy/com/github/winplay02/gitcraft/manifest/vanilla/MojangLauncherMetadataProvider.java +++ b/src/main/groovy/com/github/winplay02/gitcraft/manifest/vanilla/MojangLauncherMetadataProvider.java @@ -310,7 +310,14 @@ private String fixupSemver(String proposedSemVer) { @Override public List getParentVersions(OrderedVersion mcVersion) { List parentVersionIds = this.getParentVersionIds(mcVersion.friendlyVersion()); - return parentVersionIds == null ? null : parentVersionIds.stream().map(this::getVersionByVersionID).toList(); + return parentVersionIds == null ? null : parentVersionIds.stream() + .map(this::getVersionByVersionID) + .peek(ver -> { + if (ver == null) { + MiscHelper.panic("One or more of the parent versions were not found for %s", mcVersion.friendlyVersion()); + } + }) + .toList(); } protected List getParentVersionIds(String versionId) { @@ -320,22 +327,22 @@ protected List getParentVersionIds(String versionId) { return List.of("1.14.3-pre4"); } case "1.14_combat-0" -> { - return List.of("1.14.4", "1.14_combat-212796"); + return List.of("1.14_combat-212796", "1.14.4"); } case "1.14_combat-3" -> { return List.of("1.14_combat-0"); } case "1.15_combat-1" -> { - return List.of("1.15-pre3", "1.14_combat-3"); + return List.of("1.14_combat-3", "1.15-pre3"); } case "1.15_combat-6" -> { - return List.of("1.15.2-pre2", "1.15_combat-1"); + return List.of("1.15_combat-1", "1.15.2-pre2"); } case "1.16_combat-0" -> { - return List.of("1.16.2-pre3", "1.15_combat-6"); + return List.of("1.15_combat-6", "1.16.2-pre3"); } case "1.16_combat-1" -> { - return List.of("1.16.2", "1.16_combat-0"); + return List.of("1.16_combat-0", "1.16.2"); } case "1.16_combat-2" -> { return List.of("1.16_combat-1"); @@ -354,7 +361,7 @@ protected List getParentVersionIds(String versionId) { } // Experimental 1.18 case "1.18_experimental-snapshot-1" -> { - return List.of("1.17.1"); + return List.of("1.17.1-pre1"); } case "1.18_experimental-snapshot-2" -> { return List.of("1.18_experimental-snapshot-1"); @@ -381,9 +388,6 @@ protected List getParentVersionIds(String versionId) { case "1.19_deep_dark_experimental_snapshot-1" -> { return List.of("1.18.1"); } - case "22w11a" -> { - return List.of("1.18.2", "1.19_deep_dark_experimental_snapshot-1"); - } // Unobfuscated case "25w45a_unobfuscated" -> { return List.of("25w44a"); @@ -435,40 +439,38 @@ protected List getParentVersionIds(String versionId) { return List.of("20w13b"); } case "22w13oneblockatatime" -> { - return List.of("22w13a"); - } - case "23w13a_or_b" -> { - return List.of("23w13a_or_b_original", "23w13a"); + return List.of("1.18.2"); } case "23w13a_or_b_original" -> { return List.of("23w13a"); } - case "24w14potato" -> { - return List.of("24w14potato_original", "24w12a"); + case "23w13a_or_b" -> { + return List.of("23w13a_or_b_original"); } case "24w14potato_original" -> { return List.of("24w12a"); } + case "24w14potato" -> { + return List.of("24w14potato_original"); + } case "25w14craftmine" -> { return List.of("1.21.5"); } - // Special case to make version graph not contain a cycle - case "1.9.2" -> { - return List.of("1.9.1"); - } default -> { return null; } } } - private static final Pattern NORMAL_SNAPSHOT_PATTERN = Pattern.compile("(^\\d\\dw\\d\\d[a-z]$)|(^(1|\\d\\d).\\d+(.\\d+)?(-(pre|rc|snapshot-)\\d+|_[a-z_\\-]+snapshot-\\d+| Pre-Release \\d+)?$)"); + private static final Pattern NORMAL_SNAPSHOT_PATTERN = Pattern.compile("(^\\d\\dw\\d\\d[a-z]$)|(^(1|\\d\\d).\\d+(.\\d+)?(-(pre|rc|snapshot-)\\d+| Pre-Release \\d+)?$)"); @Override public boolean shouldExcludeFromMainBranch(OrderedVersion mcVersion) { return super.shouldExcludeFromMainBranch(mcVersion) // filter out april fools snapshots and experimental versions, // which often have typical ids that do not match normal snapshots - || (mcVersion.isSnapshotOrPending() && !NORMAL_SNAPSHOT_PATTERN.matcher(mcVersion.launcherFriendlyVersionName()).matches()); + || (mcVersion.isSnapshotOrPending() && !NORMAL_SNAPSHOT_PATTERN.matcher(mcVersion.launcherFriendlyVersionName()).matches()) + // Exclude april fools that looks like regular snapshot + || Objects.equals(mcVersion.launcherFriendlyVersionName(), "15w14a"); } } diff --git a/src/main/groovy/com/github/winplay02/gitcraft/types/OrderedVersion.java b/src/main/groovy/com/github/winplay02/gitcraft/types/OrderedVersion.java index b312496..b8d3fc1 100644 --- a/src/main/groovy/com/github/winplay02/gitcraft/types/OrderedVersion.java +++ b/src/main/groovy/com/github/winplay02/gitcraft/types/OrderedVersion.java @@ -115,6 +115,7 @@ public int javaVersion() { private static final Pattern UNOBFUSCATED_SNAPSHOT_PATTERN = Pattern.compile("^((\\d\\dw\\d\\d[a-z])|(1.\\d+(.\\d+)?-(pre|rc)\\d+))(_unobfuscated|-unobf)$"); + // Found in all manifests public boolean isSnapshot() { return Objects.equals(this.versionInfo().type(), "snapshot") // special case required because the manifest for experimental unobfuscated versions @@ -122,10 +123,12 @@ public boolean isSnapshot() { || (this.isUnobfuscated() && UNOBFUSCATED_SNAPSHOT_PATTERN.matcher(this.versionInfo().id()).matches()); } + // Can be found in Mojang and Skyrising manifests public boolean isPending() { return Objects.equals(this.versionInfo().type(), "pending"); } + // Mojang and Skyrising /** * This method is specifically for checking if this is an experimental "unobfuscated" version. * To determine whether this version has no obfuscation use {@link OrderedVersion#isNotObfuscated()}. @@ -136,7 +139,27 @@ public boolean isUnobfuscated() { || (this.isSpecial() && this.versionInfo().id().endsWith("-unobf")); } - // Can be found in Omniarchive manifest + // Mojang and Skyrising + public boolean isOldBeta() { + return Objects.equals(this.versionInfo().type(), "old_beta"); + } + + // Mojang and Skyrising + public boolean isOldAlpha() { + return Objects.equals(this.versionInfo().type(), "old_alpha"); + } + + // Skyrising + public boolean isAlphaServer() { + return Objects.equals(this.versionInfo().type(), "alpha_server"); + } + + // Skyrising + public boolean isClassicServer() { + return Objects.equals(this.versionInfo().type(), "classic_server"); + } + + // Omniarchive public boolean isSpecial() { return Objects.equals(this.versionInfo().type(), "special"); } diff --git a/src/test/groovy/com/github/winplay02/gitcraft/GitCraftTest.java b/src/test/groovy/com/github/winplay02/gitcraft/GitCraftTest.java index cdf829e..5feacb0 100644 --- a/src/test/groovy/com/github/winplay02/gitcraft/GitCraftTest.java +++ b/src/test/groovy/com/github/winplay02/gitcraft/GitCraftTest.java @@ -324,7 +324,7 @@ public void pipeline() throws Exception { } Configuration.reset(); // - GitCraft.main(new String[]{"--only-version=1.17.1,1.18_experimental-snapshot-1,21w37a,1.18,22w13oneblockatatime,25w45a_unobfuscated,1.21.11,26.1-snapshot-1"}); + GitCraft.main(new String[]{"--only-version=1.17.1-pre1,1.18_experimental-snapshot-1,21w37a,1.18,22w13oneblockatatime,25w45a_unobfuscated,1.21.11,26.1-snapshot-1"}); try (RepoWrapper repoWrapper = GitCraft.getRepository()) { assertNotNull(repoWrapper); assertNotNull(repoWrapper.getGit().getRepository().getRefDatabase().findRef(GitCraft.getRepositoryConfiguration().gitMainlineLinearBranch())); @@ -336,8 +336,8 @@ public void pipeline() throws Exception { assertEquals(1, Objects.requireNonNull(findCommit(repoWrapper, GitCraft.versionGraph.getMinecraftVersionByName("1.18"))).getParentCount()); assertEquals(2, Objects.requireNonNull(findCommit(repoWrapper, GitCraft.versionGraph.getMinecraftVersionByName("21w37a"))).getParentCount()); assertEquals(1, Objects.requireNonNull(findCommit(repoWrapper, GitCraft.versionGraph.getMinecraftVersionByName("1.18_experimental-snapshot-1"))).getParentCount()); - assertEquals(0, Objects.requireNonNull(findCommit(repoWrapper, GitCraft.versionGraph.getMinecraftVersionByName("1.17.1"))).getParentCount()); - RevCommit targetCommit = Objects.requireNonNull(findCommit(repoWrapper, GitCraft.versionGraph.getMinecraftVersionByName("1.17.1"))); + assertEquals(0, Objects.requireNonNull(findCommit(repoWrapper, GitCraft.versionGraph.getMinecraftVersionByName("1.17.1-pre1"))).getParentCount()); + RevCommit targetCommit = Objects.requireNonNull(findCommit(repoWrapper, GitCraft.versionGraph.getMinecraftVersionByName("1.17.1-pre1"))); try (TreeWalk walk = TreeWalk.forPath(repoWrapper.getGit().getRepository(), "minecraft/resources/assets", targetCommit.getTree())) { // assertNotNull(walk); } @@ -520,7 +520,7 @@ public void pipelineOldSnapshotSkyrisingOrnithe() throws Exception { @Test public void pipelineReset() throws Exception { Configuration.reset(); - GitCraft.main(new String[]{"--only-version=1.17.1,1.18_experimental-snapshot-1,21w37a,1.18,22w13oneblockatatime,25w45a_unobfuscated,1.21.11,26.1-snapshot-1", "--refresh", "--refresh-min-version=1.18"}); + GitCraft.main(new String[]{"--only-version=1.17.1-pre1,1.18_experimental-snapshot-1,21w37a,1.18,22w13oneblockatatime,25w45a_unobfuscated,1.21.11,26.1-snapshot-1", "--refresh", "--refresh-min-version=1.18"}); try (RepoWrapper repoWrapper = GitCraft.getRepository()) { assertNotNull(repoWrapper); assertNotNull(repoWrapper.getGit().getRepository().getRefDatabase().findRef(GitCraft.getRepositoryConfiguration().gitMainlineLinearBranch())); @@ -532,8 +532,8 @@ public void pipelineReset() throws Exception { assertEquals(1, Objects.requireNonNull(findCommit(repoWrapper, GitCraft.versionGraph.getMinecraftVersionByName("1.18"))).getParentCount()); assertEquals(2, Objects.requireNonNull(findCommit(repoWrapper, GitCraft.versionGraph.getMinecraftVersionByName("21w37a"))).getParentCount()); assertEquals(1, Objects.requireNonNull(findCommit(repoWrapper, GitCraft.versionGraph.getMinecraftVersionByName("1.18_experimental-snapshot-1"))).getParentCount()); - assertEquals(0, Objects.requireNonNull(findCommit(repoWrapper, GitCraft.versionGraph.getMinecraftVersionByName("1.17.1"))).getParentCount()); - RevCommit targetCommit = Objects.requireNonNull(findCommit(repoWrapper, GitCraft.versionGraph.getMinecraftVersionByName("1.17.1"))); + assertEquals(0, Objects.requireNonNull(findCommit(repoWrapper, GitCraft.versionGraph.getMinecraftVersionByName("1.17.1-pre1"))).getParentCount()); + RevCommit targetCommit = Objects.requireNonNull(findCommit(repoWrapper, GitCraft.versionGraph.getMinecraftVersionByName("1.17.1-pre1"))); try (TreeWalk walk = TreeWalk.forPath(repoWrapper.getGit().getRepository(), "minecraft/resources/assets", targetCommit.getTree())) { // assertNotNull(walk); }