Make Geyser dumps backwards compatible

This commit is contained in:
Camotoy 2022-09-11 19:26:22 -04:00
parent 25f43f3152
commit 2d7a463089
No known key found for this signature in database
GPG key ID: 7EEFB66FE798081F
3 changed files with 15 additions and 4 deletions

View file

@ -80,12 +80,16 @@ configure<BlossomExtension> {
val indra = the<IndraGitExtension>() val indra = the<IndraGitExtension>()
val mainFile = "src/main/java/org/geysermc/geyser/GeyserImpl.java" val mainFile = "src/main/java/org/geysermc/geyser/GeyserImpl.java"
val gitVersion = "git-${branchName()}-${indra.commit()?.name?.substring(0, 7) ?: "0000000"}" val commit = indra.commit()
val git = indra.git()
val gitVersion = "git-${branchName()}-${commit?.name?.substring(0, 7) ?: "0000000"}"
replaceToken("\${version}", "${project.version} ($gitVersion)", mainFile) replaceToken("\${version}", "${project.version} ($gitVersion)", mainFile)
replaceToken("\${gitVersion}", gitVersion, mainFile) replaceToken("\${gitVersion}", gitVersion, mainFile)
replaceToken("\${buildNumber}", buildNumber(), mainFile) replaceToken("\${buildNumber}", buildNumber(), mainFile)
replaceToken("\${branch}", branchName(), mainFile) replaceToken("\${branch}", branchName(), mainFile)
if (commit != null && commit.name != null) replaceToken("\${commit}", commit.name, mainFile)
if (git != null) replaceToken("\${repository}", git.repository.config.getString("remote", "origin", "url"))
} }
fun Project.branchName(): String = fun Project.branchName(): String =

View file

@ -116,6 +116,8 @@ public class GeyserImpl implements GeyserApi {
public static final String BUILD_NUMBER = "${buildNumber}"; public static final String BUILD_NUMBER = "${buildNumber}";
public static final String BRANCH = "${branch}"; public static final String BRANCH = "${branch}";
public static final String COMMIT = "${commit}";
public static final String REPOSITORY = "${repository}";
/** /**
* Oauth client ID for Microsoft authentication * Oauth client ID for Microsoft authentication

View file

@ -26,6 +26,7 @@
package org.geysermc.geyser.dump; package org.geysermc.geyser.dump;
import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.google.common.hash.Hashing; import com.google.common.hash.Hashing;
import com.google.common.io.ByteSource; import com.google.common.io.ByteSource;
@ -50,7 +51,6 @@ import org.geysermc.geyser.util.WebUtils;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
@ -89,7 +89,7 @@ public class DumpInfo {
this.systemLocale = Locale.getDefault(); this.systemLocale = Locale.getDefault();
this.systemEncoding = System.getProperty("file.encoding"); this.systemEncoding = System.getProperty("file.encoding");
this.gitInfo = new GitInfo(GeyserImpl.VERSION, GeyserImpl.BUILD_NUMBER, GeyserImpl.GIT_VERSION, GeyserImpl.BRANCH); this.gitInfo = new GitInfo(GeyserImpl.BUILD_NUMBER, GeyserImpl.COMMIT.substring(0, 7), GeyserImpl.COMMIT, GeyserImpl.BRANCH, GeyserImpl.REPOSITORY);
this.config = GeyserImpl.getInstance().getConfig(); this.config = GeyserImpl.getInstance().getConfig();
this.floodgate = new Floodgate(); this.floodgate = new Floodgate();
@ -300,9 +300,14 @@ public class DumpInfo {
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
public static class GitInfo { public static class GitInfo {
private final String version;
private final String buildNumber; private final String buildNumber;
@JsonProperty("git.commit.id.abbrev")
private final String commitHashAbbrev;
@JsonProperty("git.commit.id")
private final String commitHash; private final String commitHash;
@JsonProperty("git.branch")
private final String branchName; private final String branchName;
@JsonProperty("git.remote.origin.url")
private final String originUrl;
} }
} }