From d120903a36fb71956f729cdb30a16c7af7ba89a8 Mon Sep 17 00:00:00 2001 From: Telesphoreo Date: Mon, 18 Apr 2022 17:23:52 -0500 Subject: [PATCH] Get branch for version checking automatically --- .../0017-Change-version-fetcher-to-AMG.patch | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/patches/server/0017-Change-version-fetcher-to-AMG.patch b/patches/server/0017-Change-version-fetcher-to-AMG.patch index a545cfd..d59e8eb 100644 --- a/patches/server/0017-Change-version-fetcher-to-AMG.patch +++ b/patches/server/0017-Change-version-fetcher-to-AMG.patch @@ -5,7 +5,7 @@ Subject: [PATCH] Change version fetcher to AMG diff --git a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java -index ece77f5ea4b14bbed7c070131b3251ea86764538..a2897c410ace49d93ff4f7794e6f1472d60d1031 100644 +index ece77f5ea4b14bbed7c070131b3251ea86764538..f92610edcfb724374c69e66443eab60919ee955a 100644 --- a/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java +++ b/src/main/java/com/destroystokyo/paper/PaperVersionFetcher.java @@ -4,6 +4,8 @@ import com.destroystokyo.paper.util.VersionFetcher; @@ -17,15 +17,17 @@ index ece77f5ea4b14bbed7c070131b3251ea86764538..a2897c410ace49d93ff4f7794e6f1472 import net.kyori.adventure.text.Component; import net.kyori.adventure.text.event.ClickEvent; import net.kyori.adventure.text.format.NamedTextColor; -@@ -19,7 +21,7 @@ import java.util.stream.StreamSupport; +@@ -19,8 +21,8 @@ import java.util.stream.StreamSupport; public class PaperVersionFetcher implements VersionFetcher { private static final java.util.regex.Pattern VER_PATTERN = java.util.regex.Pattern.compile("^([0-9\\.]*)\\-.*R"); // R is an anchor, will always give '-R' at end - private static final String GITHUB_BRANCH_NAME = "master"; -+ private static final String GITHUB_BRANCH_NAME = "main"; - private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads"; +- private static final String DOWNLOAD_PAGE = "https://papermc.io/downloads"; ++ private static final String GITHUB_BRANCH_NAME = getBranch(); ++ private static final String DOWNLOAD_PAGE = "https://ci.plex.us.org/job/Scissors/job/" + GITHUB_BRANCH_NAME; private static @Nullable String mcVer; + @Override @@ -31,8 +33,8 @@ public class PaperVersionFetcher implements VersionFetcher { @Nonnull @Override @@ -37,15 +39,20 @@ index ece77f5ea4b14bbed7c070131b3251ea86764538..a2897c410ace49d93ff4f7794e6f1472 final Component history = getHistory(); return history != null ? TextComponent.ofChildren(updateMessage, Component.newline(), history) : updateMessage; -@@ -54,15 +56,19 @@ public class PaperVersionFetcher implements VersionFetcher { +@@ -54,15 +56,24 @@ public class PaperVersionFetcher implements VersionFetcher { return mcVer; } -+ // Scissors start - Allow getting git commit ++ // Scissors start - Allow getting git information + public static String getCommit() { + Map attributes = JarManifests.MANIFEST_MAP; + return attributes.get("Git-Commit"); + } ++ ++ public static String getBranch() { ++ Map attributes = JarManifests.MANIFEST_MAP; ++ return attributes.get("Git-Branch"); ++ } + // Scissors end + private static Component getUpdateStatusMessage(@Nonnull String repo, @Nonnull String branch, @Nonnull String versionInfo) {