// So that publishLocal doesn't continuously create new versions
def versionFmt(out: sbtdynver.GitDescribeOutput): String = {
val snapshotSuffix = if
(out.isSnapshot()) "-SNAPSHOT"
else ""
out.ref.dropPrefix + snapshotSuffix
}
def fallbackVersion(d: java.util.Date): String = s"HEAD-${sbtdynver.DynVer timestamp d}"
ThisBuild / version := dynverGitDescribeOutput.value.mkVersion(versionFmt, fallbackVersion(dynverCurrentDate.value))
ThisBuild / dynver := {
val d = new java.util.Date
sbtdynver.DynVer.getGitDescribeOutput(d).mkVersion(versionFmt, fallbackVersion(d))
}
The code basically means that you get basic snapshots (i.e. v1.0.0-SNAPSHOT) without any hashing/commit'ids/etc etc. The reason why this is useful is specifically for SBT plugins that have scripted tests which require local publishing (see discussion at https://github.com/sbt/sbt-osgi/pull/88#pullrequestreview-1676558140). Without this change, every single invocation of a scripted test that slightly changes the contents to make the state dirty ends up creating a new publishLocal which can quickly fill up local cache (and this is standard flow for working on sbt plugins).
One question is how this should be implemented, i.e. should we just add versionFmt/fallbackVersion as constants into sbt-dynver so that end users can just go
ThisBuild / version := dynverGitDescribeOutput.value.mkVersion(versionFmt, fallbackVersion(dynverCurrentDate.value))
ThisBuild / dynver := {
val d = new java.util.Date
sbtdynver.DynVer.getGitDescribeOutput(d).mkVersion(versionFmt, fallbackVersion(d))
}
Or should we instead do something more comprehensive, i.e. some ADT that has predefined "patterns"
sealed abstract trait VersionPattern
object VersionPattern {
case object Default extends VersionPattern // current implementation
case object Simple extends VersionPattern // whats being suggested in this PR
final case class Custom(versionFmt: sbtdynver.GitDescribeOutput => String, fallbackVersion: java.util.Date => String)
}
In both sbt-osgi and sbt-github-actions we have the following code
The code basically means that you get basic snapshots (i.e.
v1.0.0-SNAPSHOT
) without any hashing/commit'ids/etc etc. The reason why this is useful is specifically for SBT plugins that have scripted tests which require local publishing (see discussion at https://github.com/sbt/sbt-osgi/pull/88#pullrequestreview-1676558140). Without this change, every single invocation of a scripted test that slightly changes the contents to make the state dirty ends up creating a newpublishLocal
which can quickly fill up local cache (and this is standard flow for working on sbt plugins).One question is how this should be implemented, i.e. should we just add
versionFmt
/fallbackVersion
as constants into sbt-dynver so that end users can just goOr should we instead do something more comprehensive, i.e. some ADT that has predefined "patterns"