Skip to content

Commit

Permalink
Fail if tag is older than base version #105
Browse files Browse the repository at this point in the history
  • Loading branch information
osleonard committed Feb 4, 2022
1 parent 3f7660d commit c3b9792
Showing 1 changed file with 17 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,27 +73,27 @@ object TypelevelVersioningPlugin extends AutoPlugin {
.previousReleases(true)
.filterNot(_.isPrerelease) // TODO Ordering of pre-releases is arbitrary
.headOption
.flatMap { previous =>
if (previous > baseV)
sys.error(s"Your tlBaseVersion $baseV is behind the latest tag $previous")
else if (baseV.isSameSeries(previous))
Some(previous)
else
None
}

// version here is the prefix used further to build a final version number
var version = latestInSeries.fold(tlBaseVersion.value)(_.toString)

latestInSeries.flatMap { previous =>
if (previous > baseV)
sys.error(s"Your tlBaseVersion $baseV is behind the latest tag $previous")
else if (version < baseV.toString)
sys.error(s"Your latest tag $version cannot be less than tlBaseVersion $baseV")
else if (baseV.isSameSeries(previous))
Some(previous)
else
None
}

// Looks for the distance to latest release in this series
latestInSeries.foreach { latestInSeries =>
Try(s"git describe --tags --match v$latestInSeries".!!.trim)
.collect { case Description(distance) => distance }
.foreach { distance => version += s"-$distance" }
}
if (version < baseV.toString)
sys.error(s"Your latest tag $version cannot be less than tlBaseVersion $baseV")
else
// Looks for the distance to latest release in this series
latestInSeries.foreach { latestInSeries =>
Try(s"git describe --tags --match v$latestInSeries".!!.trim)
.collect { case Description(distance) => distance }
.foreach { distance => version += s"-$distance" }
}

git.gitHeadCommit.value.foreach { sha => version += s"-${sha.take(7)}" }
version
Expand Down

0 comments on commit c3b9792

Please sign in to comment.