Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions versions/shared/src/coursier/version/Version.scala
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ object Version {
case "dev" => Tag.devLevel
case "alpha" => Tag.alphaLevel
case "beta" => Tag.betaLevel
case "pre" => Tag.preLevel
case "milestone" => Tag.milestoneLevel
case "rc" | "cr" => Tag.rcLevel
case "snapshot" => Tag.snapshotLevel
Expand Down Expand Up @@ -183,10 +184,12 @@ object Version {
// Qualifiers, in order. Those below emptyLevel denote pre-releases, those above it
// denote releases. Unlike Maven, ga and final are distinct, and distinct from the empty
// item, so that no two of them compare equal and sorting versions stays deterministic.
// dev isn't part of the documented ordering, it's kept as an extension, below alpha.
private[version] val devLevel = -6
private[version] val alphaLevel = -5
private[version] val betaLevel = -4
// dev and pre aren't part of the documented ordering, they are kept as extensions,
// below alpha for dev, and between beta and milestone for pre.
private[version] val devLevel = -7
private[version] val alphaLevel = -6
private[version] val betaLevel = -5
private[version] val preLevel = -4
private[version] val milestoneLevel = -3
private[version] val rcLevel = -2
private[version] val snapshotLevel = -1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,11 @@ object VersionCompatibilityTests extends TestSuite {
"1.2.3-beta2",
"1.2.3-SNAPSHOT",
"1.2.3-milestone2",
"1.2.3-pre2",
// well-known markers count as pre-releases wherever they show up
"1.2.3.RC1",
"1.2.3.SNAPSHOT"
"1.2.3.SNAPSHOT",
"1.2.3.pre2"
)
for (compat <- compatibilities; wanted <- preReleases) {
val compatible = compat.isCompatible(wanted, "1.9.9")
Expand Down
11 changes: 9 additions & 2 deletions versions/shared/test/src/coursier/version/VersionTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,8 @@ object VersionTests extends TestSuite {
assert(compare("1-alpha1", "1-a1" ) == 0)
assert(compare("1-alpha", "1-beta" ) < 0)
assert(compare("1-beta1", "1-b1" ) == 0)
assert(compare("1-beta", "1-milestone" ) < 0)
assert(compare("1-beta", "1-pre" ) < 0)
assert(compare("1-pre", "1-milestone" ) < 0)
assert(compare("1-milestone1", "1-m1" ) == 0)
assert(compare("1-milestone", "1-rc" ) < 0)
assert(compare("1-rc", "1-cr" ) == 0)
Expand Down Expand Up @@ -257,6 +258,7 @@ object VersionTests extends TestSuite {
assert(compare("1-abc", "1-alpha" ) > 0)
assert(compare("1-abc", "1-beta" ) > 0)
assert(compare("1-abc", "1-milestone" ) > 0)
assert(compare("1-abc", "1-pre" ) > 0)
assert(compare("1-abc", "1-rc" ) > 0)
assert(compare("1-abc", "1-snapshot" ) > 0)
assert(compare("1-abc", "1" ) > 0)
Expand Down Expand Up @@ -427,6 +429,9 @@ object VersionTests extends TestSuite {
// M1 is a milestone, while MF, X1 and a are plain literal items, which sort
// after 1.0 rather than before it
assert(increasing( "1.0-alpha1", "1.0-M1", "1.0-RC1", "1.0", "1.0-MF", "1.0-X1", "2.0", "2.0.2"))
assert(increasing( "1.0.0-alpha3", "1.0.0-beta3", "1.0.0-pre3", "1.0.0-M3", "1.0.0-RC3", "1.0.0" ))
assert(increasing( "1.0.0-pre1", "1.0.0-pre2", "1.0.0-PRE10", "1.0.0" ))
assert(increasing( "1.0.0.pre3", "1.0.0" ))
assert(increasing( "1.0-RC1", "1.0", "1.0a", "1.0-MF", "1.0-X1", "2.0", "2.0.2"))
}

Expand Down Expand Up @@ -625,8 +630,10 @@ object VersionTests extends TestSuite {
// cr and rc are two spellings of the same qualifier, so are m1 and milestone1
assert(compare("1-cr", "1-rc") == 0)
assert(compare("1-m1", "1-milestone1") == 0)
// dev is a coursier extension, it isn't part of the documented list
// dev and pre are coursier extensions, they aren't part of the documented list
assert(compare("1-dev", "1-alpha") < 0)
assert(compare("1-beta", "1-pre") < 0)
assert(compare("1-pre", "1-milestone") < 0)
}
}

Expand Down