We're using SBT with sbt-git to derive the version of our build from the Git revision. Specifically, we're using the output from git describe
as version number and append the "SNAPSHOT" qualifier when the current revision is not tagged:
val versionRegex = "v([0-9]+.[0-9]+.[0-9]+)-?(.*)?".r
git.useGitDescribe := true
git.baseVersion := "0.0.0"
git.gitTagToVersionNumber := {
case versionRegex(v, "") => Some(v)
case versionRegex(v, "SNAPSHOT") => Some(s"$v-SNAPSHOT")
case versionRegex(v, s) => Some(s"$v-$s-SNAPSHOT")
case _ => None
}
However, this sometimes results the qualifier being duplicated, i.e. version numbers like "0.0.0-12345678-SNAPSHOT-SNAPSHOT".
I can find no apparent reason for that. Removing "-SNAPSHOT" from the gitTagToVersionNumber
solves the issue, but removes the qualifier completely in other cases.
sbt-git will append an additional qualifier when there are uncommited changes in the Git working copy during the build.
By default, this qualifier is set to "SNAPSHOT". One can change it through the uncommittedSignifier
setting, e.g.:
git.uncommittedSignifier := Some("DIRTY")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With