Add falback if branch command fails

This commit is contained in:
Lukas Rieger (Blue) 2024-12-07 12:55:20 +01:00
parent 4be0b48600
commit 124cbc6db6
No known key found for this signature in database
GPG Key ID: AA33883B1BBA03E6
2 changed files with 2 additions and 2 deletions

2
api

@ -1 +1 @@
Subproject commit 768daee3c4c80f7c1c2c3096241818c27c7b5fa2
Subproject commit 67a7352c672d054b9e6cd0e996a4fa92ba0c237e

View File

@ -15,7 +15,7 @@ fun Project.gitVersion(): String {
val lastTag = if (runCommand("git tag", "").isEmpty()) "" else runCommand("git describe --tags --abbrev=0", "")
val lastVersion = if (lastTag.isEmpty()) "0.0" else lastTag.substring(1) // remove the leading 'v'
val commits = runCommand("git rev-list --count $lastTag..HEAD", "0")
val branch = runCommand("git branch --show-current")
val branch = runCommand("git branch --show-current", "master")
val gitVersion = lastVersion +
(if (branch == "master") "" else "-${branch.replace('/', '.')}") +
(if (commits == "0") "" else "-$commits") +