diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml index f914f80c..b0ef13ab 100644 --- a/.github/workflows/gradle.yml +++ b/.github/workflows/gradle.yml @@ -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 diff --git a/BlueMapAPI b/BlueMapAPI index b466fb4e..c40eb72d 160000 --- a/BlueMapAPI +++ b/BlueMapAPI @@ -1 +1 @@ -Subproject commit b466fb4ed8655d0b6212c7343594886753a0c21a +Subproject commit c40eb72d7c35f4c25a3a52320e457537cbec1d9f diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java index 975cc891..bd09b776 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/plugin/commands/Commands.java @@ -322,7 +322,7 @@ public class Commands { 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 { 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" + diff --git a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/BlueMapResponseModifier.java b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/BlueMapResponseModifier.java index 2eed01af..7dd0792e 100644 --- a/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/BlueMapResponseModifier.java +++ b/BlueMapCommon/src/main/java/de/bluecolored/bluemap/common/web/BlueMapResponseModifier.java @@ -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 diff --git a/BlueMapCore/build.gradle.kts b/BlueMapCore/build.gradle.kts index 58de11e9..9810d51d 100644 --- a/BlueMapCore/build.gradle.kts +++ b/BlueMapCore/build.gradle.kts @@ -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 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)", ) } } diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/BlueMap.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/BlueMap.java index efe18888..9801d58b 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/BlueMap.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/BlueMap.java @@ -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( diff --git a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/debug/StateDumper.java b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/debug/StateDumper.java index 9a6ea4f8..dedc672e 100644 --- a/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/debug/StateDumper.java +++ b/BlueMapCore/src/main/java/de/bluecolored/bluemap/core/debug/StateDumper.java @@ -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", diff --git a/BlueMapCore/src/main/resources/de/bluecolored/bluemap/version.json b/BlueMapCore/src/main/resources/de/bluecolored/bluemap/version.json index d1d2c538..e5a5f178 100644 --- a/BlueMapCore/src/main/resources/de/bluecolored/bluemap/version.json +++ b/BlueMapCore/src/main/resources/de/bluecolored/bluemap/version.json @@ -1,5 +1,4 @@ { "version": "${version}", - "git-hash": "${gitHash}", - "git-clean": "${gitClean}" + "git-hash": "${gitHash}" } \ No newline at end of file