Skip to content

Commit

Permalink
Add falback if branch command fails
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlueF committed Dec 7, 2024
1 parent 768daee commit 67a7352
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/versioning.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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") +
Expand Down

0 comments on commit 67a7352

Please sign in to comment.