Skip to content

Commit

Permalink
fix commit out of order issues
Browse files Browse the repository at this point in the history
  • Loading branch information
SpaceWalkerRS committed Jun 18, 2024
1 parent da466ff commit 32f8296
Showing 1 changed file with 43 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Objects;

import com.github.winplay02.gitcraft.meta.LauncherMeta;
import com.github.winplay02.gitcraft.meta.VersionDetails;
Expand Down Expand Up @@ -76,21 +77,50 @@ protected String lookupSemanticVersion(VersionMeta versionMeta) {

@Override
public List<String> getParentVersion(OrderedVersion mcVersion) {
List<String> versions = new ArrayList<>();

for (String versionId : getVersionDetails(mcVersion.launcherFriendlyVersionName()).previous()) {
// Skyrising's manifest does not have a version with id rd-132211
// yet version rd-132211-launcher lists it as its previous version
if ("rd-132211".equals(versionId)) {
continue;
}
// see comment in unpackLauncherMetaEntry for why ancient server is ignored
if (versionId.startsWith("server-")) {
continue;
List<String> parentVersions = new ArrayList<>();

if (!patchParentVersions(mcVersion, parentVersions)) {
VersionDetails details = getVersionDetails(mcVersion.launcherFriendlyVersionName());

for (String parentVersion : details.previous()) {
// Skyrising's manifest does not have a version with id rd-132211
// yet version rd-132211-launcher lists it as its previous version
if ("rd-132211".equals(parentVersion)) {
continue;
}
// see comment in unpackLauncherMetaEntry for why ancient server is ignored
if (parentVersion.startsWith("server-")) {
continue;
}

VersionDetails parentDetails = getVersionDetails(parentVersion);
parentVersions.add(parentDetails.normalizedVersion());
}
versions.add(getVersionDetails(versionId).normalizedVersion());
}

return versions;
return parentVersions;
}

// hopefully this will be replaced by more sophisticated branching logic
// in the version graph and commit step
private boolean patchParentVersions(OrderedVersion mcVersion, List<String> parentVersions) {
String patchedParentVersion = switch (mcVersion.launcherFriendlyVersionName()) {
case "12w32a" -> "1.3.2"; // 1.3.1
case "12w34a" -> "12w32a"; // [1.3.2, 12w32a]
case "13w16-04192037" -> "1.5.2"; // 1.5.1
case "13w36a-09051446" -> "1.6.4"; // 1.6.2-091847
case "14w02a" -> "1.7.10"; // 1.7.4
case "15w31a" -> "1.8.9"; // 1.8.8
default -> null;
};

if (patchedParentVersion == null) {
return false;
}

VersionDetails parentDetails = getVersionDetails(patchedParentVersion);
parentVersions.add(parentDetails.normalizedVersion());

return true;
}
}

0 comments on commit 32f8296

Please sign in to comment.