Skip to content

Commit

Permalink
Merge pull request #1148 from fthomas/topic/tweak-selectNext
Browse files Browse the repository at this point in the history
Do not select versions with a hyphen
  • Loading branch information
fthomas authored Dec 10, 2019
2 parents e3297e5 + 5ce0963 commit 6965665
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,20 @@ final case class Version(value: String) {
case (commonPrefix, vs) =>
// Do not select pre-release versions of a different series.
val vs1 = vs.filterNot(_.isPreRelease && cutoff =!= commonPrefix.length)
// Do not select dynamic versions if this is not a dynamic version.
// E.g. 1.2.0 -> 1.2.0+17-7ef98061.
val vs2 = vs1.filterNot(_.containsPlus && !containsPlus)
// Do not select versions with a '+' or '-' if this is version does not
// contain such separator.
// E.g. 1.2.0 -> 1.2.0+17-7ef98061 or 3.1.0 -> 3.1.0-2156c0e.
val vs2 = vs1.filterNot { v =>
(v.containsHyphen && !containsHyphen) || (v.containsPlus && !containsPlus)
}
vs2.sorted
}
.lastOption
}

private def containsHyphen: Boolean =
components.contains(Version.Component.Separator('-'))

private def containsPlus: Boolean =
components.contains(Version.Component.Separator('+'))

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,10 @@ class VersionTest extends AnyFunSuite with Discipline with Matchers with ScalaCh
("1.2.0", List("1.2.0+17-7ef98061"), None),
("1.2.0+17-7ef98061", List("1.3.0"), Some("1.3.0")),
("2.4.4", List("3.0.0-preview"), None),
("2.3.2", List("2.3.3-b02"), None)
("2.3.2", List("2.3.3-b02"), None),
("3.1.0", List("3.1.0-2156c0e"), None),
("3.1.0-2156c0e", List("3.2.0"), Some("3.2.0")),
("1.6.7", List("1.6.7-2-c28002d"), None)
)

val rnd = new Random()
Expand Down

0 comments on commit 6965665

Please sign in to comment.