Skip to content

Commit 1eb9982

Browse files
authored
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".
1 parent e2037e9 commit 1eb9982

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

BlueMapCore/build.gradle.kts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ fun String.runCommand(): String = ProcessBuilder(split("\\s(?=(?:[^'\"`]*(['\"`]
2828

2929
val gitHash = "git rev-parse --verify HEAD".runCommand()
3030
val clean = "git status --porcelain".runCommand().isEmpty()
31-
val lastTag = "git describe --tags --abbrev=0".runCommand()
32-
val lastVersion = lastTag.substring(1) // remove the leading 'v'
31+
val lastTag = if ("git tag".runCommand().isEmpty()) "" else "git describe --tags --abbrev=0".runCommand()
32+
val lastVersion = if (lastTag.isEmpty()) "dev" else lastTag.substring(1) // remove the leading 'v'
3333
val commits = "git rev-list --count $lastTag..HEAD".runCommand()
3434
println("Git hash: $gitHash" + if (clean) "" else " (dirty)")
3535

0 commit comments

Comments
 (0)