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.