Skip to content

Commit

Permalink
Revert "Remove version.sbt to avoid confusion, usually that's where w…
Browse files Browse the repository at this point in the history
…e hardcode the version"

This reverts commit 49df240.
  • Loading branch information
mkurz committed May 17, 2022
1 parent fcb77ce commit 0a11276
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 37 deletions.
37 changes: 0 additions & 37 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,6 @@ import Common._
import com.typesafe.tools.mima.core._
import com.typesafe.tools.mima.plugin.MimaKeys.{ mimaBinaryIssueFilters, mimaPreviousArtifacts }

// Customise sbt-dynver's behaviour to make it work with tags which aren't v-prefixed
ThisBuild / dynverVTagPrefix := false

(ThisBuild / version) := {
val Stable = """([0-9]+)\.([0-9]+)\.([0-9]+)""".r

(ThisBuild / dynverGitDescribeOutput).value match {
case Some(descr) => {
if ((ThisBuild / isSnapshot).value) {
(ThisBuild / previousStableVersion).value match {
case Some(previousVer) => {
val current = (for {
Seq(maj, min, patch) <- Stable.unapplySeq(previousVer)
nextPatch <- scala.util.Try(patch.toInt).map(_ + 1).toOption
} yield {
val suffix = descr.commitSuffix.sha
s"${maj}.${min}.${nextPatch}-${suffix}-SNAPSHOT"
}).getOrElse {
sys.error("Fails to determine qualified snapshot version")
}

current
}

case _ =>
sys.error("Fails to determine previous stable version")
}
} else {
descr.ref.value // without 'v' prefix
}
}

case _ =>
sys.error("Fails to resolve Git information")
}
}

/* TODO
// Scalafix
inThisBuild(
Expand Down
35 changes: 35 additions & 0 deletions version.sbt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
ThisBuild / dynverVTagPrefix := false

(ThisBuild / version) := {
val Stable = """([0-9]+)\.([0-9]+)\.([0-9]+)""".r

(ThisBuild / dynverGitDescribeOutput).value match {
case Some(descr) => {
if ((ThisBuild / isSnapshot).value) {
(ThisBuild / previousStableVersion).value match {
case Some(previousVer) => {
val current = (for {
Seq(maj, min, patch) <- Stable.unapplySeq(previousVer)
nextPatch <- scala.util.Try(patch.toInt).map(_ + 1).toOption
} yield {
val suffix = descr.commitSuffix.sha
s"${maj}.${min}.${nextPatch}-${suffix}-SNAPSHOT"
}).getOrElse {
sys.error("Fails to determine qualified snapshot version")
}

current
}

case _ =>
sys.error("Fails to determine previous stable version")
}
} else {
descr.ref.value // without 'v' prefix
}
}

case _ =>
sys.error("Fails to resolve Git information")
}
}

0 comments on commit 0a11276

Please sign in to comment.