Skip to content

Commit

Permalink
Add branch to version if not master
Browse files Browse the repository at this point in the history
  • Loading branch information
TBlueF committed Dec 7, 2024
1 parent 9f338da commit 768daee
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions buildSrc/src/main/kotlin/versioning.kt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ 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 gitVersion = lastVersion +
(if (branch == "master") "" else "-${branch.replace('/', '.')}") +
(if (commits == "0") "" else "-$commits") +
(if (gitClean()) "" else "-dirty")

Expand Down

0 comments on commit 768daee

Please sign in to comment.