Skip to content

Commit

Permalink
Merge pull request #1553 from scala-steward-org/topic/prevent-RC-to-R…
Browse files Browse the repository at this point in the history
…C-SNAPSHOT

Prevent updates to less stable pre-release versions
  • Loading branch information
fthomas authored Jul 29, 2020
2 parents 144fc8a + 3d67d1b commit c7580e7
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ final case class Version(value: String) {
(v.isPreRelease && !sameSeries) ||
// Do not select pre-releases of the same series if this is not a pre-release.
(v.isPreRelease && !isPreRelease && sameSeries) ||
// Do not select versions with pre-release identifiers whose order is smaller
// than the order of pre-release identifiers in this version. This, for example,
// prevents updates from 2.1.4.0-RC17 to 2.1.4.0-RC17+1-307f2f6c-SNAPSHOT.
((minAlphaOrder < 0) && (v.minAlphaOrder < minAlphaOrder)) ||
// Don't select "versions" like %5BWARNING%5D.
!v.startsWithLetterOrDigit
}.sorted
Expand Down Expand Up @@ -88,6 +92,12 @@ final case class Version(value: String) {

private[this] def hashIndex: Option[NonNegInt] =
"""[-+]\p{XDigit}{6,}""".r.findFirstMatchIn(value).flatMap(m => NonNegInt.unapply(m.start))

private val minAlphaOrder: Int =
alnumComponents
.collect { case a @ Version.Component.Alpha(_) => a.order }
.minOption
.getOrElse(0)
}

object Version {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ class VersionTest
("0.19.0-RC1", List("0.20.0-RC1", "0.20.0"), Some("0.20.0")),
("0.19.0-RC1", List("0.20.0-RC1", "0.21.0-RC1"), None),
("1.14.0", List("1.14.1-RC1", "1.14.1", "1.14.2"), Some("1.14.2")),
("3.0.8-RC2", List("3.1.0-SNAP10"), None),
("3.1.0-SNAP13", List("3.2.0-M1"), None),
("3.1.0-SNAP13", List("3.2.0-M1", "3.2.0"), Some("3.2.0")),
("4.1.42.Final", List("5.0.0.Alpha2"), None),
Expand Down Expand Up @@ -191,6 +192,9 @@ class VersionTest
("0.6.3", List("289f9e3aa3f5014a5c64319da8e6ab993947ade2-0-289f9e"), None),
("0.1-58d9629", List("0.8.0"), Some("0.8.0")),
("0.9-a3bf234", List("0.14-9419610"), Some("0.14-9419610")),
("0.21.0-RC5", List("0.21.6", "0.21.6+43-2c1c1172-SNAPSHOT"), Some("0.21.6")),
("0.21.0-RC5", List("0.21.5", "0.21.6-RC1"), Some("0.21.6-RC1")),
("2.1.4.0-RC17", List("2.1.4.0-RC17+1-307f2f6c-SNAPSHOT"), None),
("v2-rev374-1.23.0", List("v2-rev20190917-1.30.3"), Some("v2-rev20190917-1.30.3"))
)

Expand Down

0 comments on commit c7580e7

Please sign in to comment.