Change git-hash detection, fix ci

This commit is contained in:
Lukas Rieger (Blue) 2022-07-26 22:04:01 +02:00
parent d924383fb2
commit 95e3211a4a
No known key found for this signature in database
GPG Key ID: 2D09EC5ED2687FF2
8 changed files with 27 additions and 18 deletions

View File

@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
with:
submodules: recursive
- name: Set up JDK 1.17
uses: actions/setup-java@v1

@ -1 +1 @@
Subproject commit b466fb4ed8655d0b6212c7343594886753a0c21a
Subproject commit c40eb72d7c35f4c25a3a52320e457537cbec1d9f

View File

@ -322,7 +322,7 @@ public class Commands<S> {
MinecraftVersion minecraftVersion = plugin.getServerInterface().getMinecraftVersion();
source.sendMessage(Text.of(TextFormat.BOLD, TextColor.BLUE, "Version: ", TextColor.WHITE, BlueMap.VERSION));
source.sendMessage(Text.of(TextColor.GRAY, "Commit: ", TextColor.WHITE, BlueMap.GIT_HASH + " (" + BlueMap.GIT_CLEAN + ")"));
source.sendMessage(Text.of(TextColor.GRAY, "Commit: ", TextColor.WHITE, BlueMap.GIT_HASH));
source.sendMessage(Text.of(TextColor.GRAY, "Implementation: ", TextColor.WHITE, plugin.getImplementationType()));
source.sendMessage(Text.of(
TextColor.GRAY, "Minecraft compatibility: ", TextColor.WHITE, minecraftVersion.getVersionString(),
@ -335,7 +335,7 @@ public class Commands<S> {
if (minecraftVersion.isAtLeast(new MinecraftVersion(1, 15))) {
String clipboardValue =
"Version: " + BlueMap.VERSION + "\n" +
"Commit: " + BlueMap.GIT_HASH + " (" + BlueMap.GIT_CLEAN + ")\n" +
"Commit: " + BlueMap.GIT_HASH + "\n" +
"Implementation: " + plugin.getImplementationType() + "\n" +
"Minecraft compatibility: " + minecraftVersion.getVersionString() + " (" + minecraftVersion.getResource().getVersion().getVersionString() + ")\n" +
"Render-threads: " + renderThreadCount + "\n" +

View File

@ -13,7 +13,7 @@ public class BlueMapResponseModifier implements HttpRequestHandler {
public BlueMapResponseModifier(HttpRequestHandler delegate) {
this.delegate = delegate;
this.serverName = "BlueMap " + BlueMap.VERSION + " " + BlueMap.GIT_HASH + " " + BlueMap.GIT_CLEAN;
this.serverName = "BlueMap " + BlueMap.VERSION + " " + BlueMap.GIT_HASH;
}
@Override

View File

@ -1,14 +1,29 @@
import java.util.Properties
import java.io.IOException
plugins {
java
`java-library`
id("com.diffplug.spotless") version "6.1.2"
id ("com.palantir.git-version") version "0.12.3"
}
val versionDetails: groovy.lang.Closure<com.palantir.gradle.gitversion.VersionDetails> by extra
val git = versionDetails()
fun String.runCommand(): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`])[^'\"`]*\\1)*[^'\"`]*$)".toRegex()))
.directory(projectDir)
.redirectOutput(ProcessBuilder.Redirect.PIPE)
.redirectError(ProcessBuilder.Redirect.PIPE)
.start()
.apply { waitFor(60, TimeUnit.SECONDS) }
.run {
val error = errorStream.bufferedReader().readText().trim()
if (error.isNotEmpty()) {
throw IOException(error)
}
inputStream.bufferedReader().readText().trim()
}
val gitHash = "git rev-parse --verify HEAD".runCommand()
val clean = "git status --porcelain".runCommand().isEmpty()
println("Git hash: $gitHash" + if (clean) "" else " (dirty)")
val releaseProperties = Properties()
releaseProperties.load(file("../release.properties").inputStream())
@ -79,8 +94,7 @@ tasks.processResources {
expand (
"version" to project.version,
"gitHash" to git.gitHashFull,
"gitClean" to git.isCleanTag
"gitHash" to gitHash + if (clean) "" else " (dirty)",
)
}
}

View File

@ -34,9 +34,9 @@ import java.util.concurrent.ForkJoinWorkerThread;
public class BlueMap {
public static final String VERSION, GIT_HASH, GIT_CLEAN;
public static final String VERSION, GIT_HASH;
static {
String version = "DEV", gitHash = "DEV", gitClean = "DEV";
String version = "DEV", gitHash = "DEV";
try {
ConfigurationNode node = GsonConfigurationLoader.builder()
.url(BlueMap.class.getResource("/de/bluecolored/bluemap/version.json"))
@ -45,18 +45,15 @@ public class BlueMap {
version = node.node("version").getString("DEV");
gitHash = node.node("git-hash").getString("DEV");
gitClean = node.node("git-clean").getString("DEV");
} catch (IOException ex) {
Logger.global.logError("Failed to load version.json from resources!", ex);
}
if (version.equals("${version}")) version = "DEV";
if (gitHash.equals("${gitHash}")) version = "DEV";
if (gitClean.equals("${gitClean}")) version = "DEV";
VERSION = version;
GIT_HASH = gitHash;
GIT_CLEAN = gitClean;
}
public static final ForkJoinPool THREAD_POOL = new ForkJoinPool(

View File

@ -229,7 +229,6 @@ public class StateDumper {
private void collectSystemInfo(ConfigurationNode node) throws SerializationException {
node.node("bluemap-version").set(BlueMap.VERSION);
node.node("git-hash").set(BlueMap.GIT_HASH);
node.node("git-clean").set(BlueMap.GIT_CLEAN);
String[] properties = new String[]{
"java.runtime.name",

View File

@ -1,5 +1,4 @@
{
"version": "${version}",
"git-hash": "${gitHash}",
"git-clean": "${gitClean}"
"git-hash": "${gitHash}"
}