F30
F30

Reputation: 1192

Building packages using sbt-git results in "SNAPSHOT-SNAPSHOT" version qualifier

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.

Upvotes: 5

Views: 498

Answers (1)

F30
F30

Reputation: 1192

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")

Upvotes: 9

Related Questions