Skip to content

Commit 768daee

Browse files
committed
Add branch to version if not master
1 parent 9f338da commit 768daee

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

buildSrc/src/main/kotlin/versioning.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ fun Project.gitVersion(): String {
1515
val lastTag = if (runCommand("git tag", "").isEmpty()) "" else runCommand("git describe --tags --abbrev=0", "")
1616
val lastVersion = if (lastTag.isEmpty()) "0.0" else lastTag.substring(1) // remove the leading 'v'
1717
val commits = runCommand("git rev-list --count $lastTag..HEAD", "0")
18+
val branch = runCommand("git branch --show-current")
1819
val gitVersion = lastVersion +
20+
(if (branch == "master") "" else "-${branch.replace('/', '.')}") +
1921
(if (commits == "0") "" else "-$commits") +
2022
(if (gitClean()) "" else "-dirty")
2123

0 commit comments

Comments
 (0)