Apply version number parsing fix

Ref #377

Apply the dotted-prerelease tag to SemComparator
"A pre-release version MAY be denoted by appending a hyphen and a series of dot separated identifiers immediately following the patch version."
This commit is contained in:
Eugene Yokota 2021-05-15 14:12:46 -04:00
parent af46c23d5b
commit 0ce5142b17
3 changed files with 18 additions and 3 deletions

View File

@ -148,7 +148,7 @@ private[librarymanagement] abstract class SemComparatorFunctions {
(?:\.(\d+|[xX*])
(?:\.(\d+|[xX*]))?
)?
)((?:-\w+)*)$
)((?:-\w+(?:\.\w+)*)*)$
""".r
protected def parse(comparator: String): SemComparator = {
comparator match {

View File

@ -66,7 +66,7 @@ object VersionNumber {
def splitDash(s: String) = splitOn(s, '-')
def splitPlus(s: String) = splitOn(s, '+') map ("+" + _)
val TaggedVersion = """(\d{1,14})([\.\d{1,14}]*)((?:-[\w\.]+)*)((?:\+.+)*)""".r
val TaggedVersion = """(\d{1,14})([\.\d{1,14}]*)((?:-\w+(?:\.\w+)*)*)((?:\+.+)*)""".r
val NonSpaceString = """(\S+)""".r
s match {

View File

@ -75,6 +75,7 @@ class SemanticSelectorSpec extends AnyFreeSpec with Matchers {
semsel(">=1.2.3") { sel =>
assertMatches(sel, "1.2.4-beta")
assertMatches(sel, "1.2.4-beta.1")
assertMatches(sel, "1.2.3")
assertMatches(sel, "1.3")
assertMatches(sel, "2")
@ -306,6 +307,21 @@ class SemanticSelectorSpec extends AnyFreeSpec with Matchers {
assertNotMatches(sel, "1.2.2")
}
semsel(">=1.2.3-beta.5") { sel =>
assertMatches(sel, "1.3-alpha")
assertMatches(sel, "1.2.3")
assertMatches(sel, "1.2.3-beta.5")
assertMatches(sel, "1.2.3-beta.6-3")
assertMatches(sel, "1.2.3-beta.7")
assertMatches(sel, "1.2.3-beta.gamma")
assertMatches(sel, "1.2.4")
assertMatches(sel, "1.3")
assertNotMatches(sel, "1.2.3-alpha-3")
assertNotMatches(sel, "1.2.3-beta-1")
assertNotMatches(sel, "1.2.3-beta")
assertNotMatches(sel, "1.2.2")
}
Seq(
// invalid operator
"~1.2.3",
@ -339,7 +355,6 @@ class SemanticSelectorSpec extends AnyFreeSpec with Matchers {
"1.0.0 - 2.0.0 || - 2.0.0",
"1.0.0- 2.0.0",
"1.0.0 -2.0.0",
"1.0.0-2.0.0",
"-",
// minor and patch versions are required for pre-release version
"1.2-alpha-beta",