From 1eb9982357e4eded45fe31808b22b91d124db1ee Mon Sep 17 00:00:00 2001 From: Carey Metcalfe Date: Fri, 19 May 2023 04:14:31 -0600 Subject: [PATCH] Allow the build to work in cases where the current repo has no tags (#434) When forking the project on GitHub there is an option to only fork the main repo branch. This means that the forked repo will not have any tags in it which currently causes the build system to fail. This change adds a fallback in the case that there are no tags to building a version named "-dev-dirty". --- BlueMapCore/build.gradle.kts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/BlueMapCore/build.gradle.kts b/BlueMapCore/build.gradle.kts index 17fa9c2b..7f1a16d2 100644 --- a/BlueMapCore/build.gradle.kts +++ b/BlueMapCore/build.gradle.kts @@ -28,8 +28,8 @@ fun String.runCommand(): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`] val gitHash = "git rev-parse --verify HEAD".runCommand() val clean = "git status --porcelain".runCommand().isEmpty() -val lastTag = "git describe --tags --abbrev=0".runCommand() -val lastVersion = lastTag.substring(1) // remove the leading 'v' +val lastTag = if ("git tag".runCommand().isEmpty()) "" else "git describe --tags --abbrev=0".runCommand() +val lastVersion = if (lastTag.isEmpty()) "dev" else lastTag.substring(1) // remove the leading 'v' val commits = "git rev-list --count $lastTag..HEAD".runCommand() println("Git hash: $gitHash" + if (clean) "" else " (dirty)")