Skip to content

Commit b49da08

Browse files
committed
minor git version tweaks
1 parent 84bf50e commit b49da08

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

settings.gradle.kts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ val currentCommitHash: Provider<String> =
9696
isIgnoreExitValue = true
9797
}.standardOutput.asText.map { it.trim() }
9898

99-
val semverRegex = Regex("""v[0-9]+\.[0-9]+\.[0-9]+""")
99+
val semverRegex = Regex("""v(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)\.(?:0|[1-9][0-9]*)""")
100100

101101
val gitVersion: Provider<String> =
102102
gitDescribe.zip(currentBranchName) { described, branch ->
@@ -108,9 +108,9 @@ val gitVersion: Provider<String> =
108108
val descriptions = described.split("-")
109109
val head = descriptions.singleOrNull() ?: ""
110110
val headIsVersioned = head.matches(semverRegex)
111-
if (headIsVersioned) head else "$branch-SNAPSHOT"
111+
if (headIsVersioned) head else currentCommitHash.get() // fall back to using the git commit hash
112112
}
113-
}.orElse(currentCommitHash) // fall back to using the git commit hash
113+
}
114114

115115
gradle.allprojects {
116116
extensions.add<Provider<String>>("gitVersion", gitVersion)

0 commit comments

Comments
 (0)