Skip to content

Commit

Permalink
Fixed prerelease comparision - references #1316
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jan 7, 2016
1 parent bf1c91e commit afbb34f
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 1 deletion.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#### 2.40.15 - 07.01.2016
* BUGFIX: Fixed prerelease comparision - https://github.com/fsprojects/Paket/issues/1316

#### 2.40.14 - 07.01.2016
* BUGFIX: Fixed problem with prerelease versions during pack - https://github.com/fsprojects/Paket/issues/1316

Expand Down
2 changes: 2 additions & 0 deletions src/Paket.Core/SemVer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ type SemVerInfo =
| None, None -> 0
| Some p, None -> -1
| None, Some p -> 1
| Some p, _ when p.ToString() = "prerelease" -> -1
| _, Some p when p.ToString() = "prerelease" -> 1
| Some left, Some right -> compare left right

| _ -> invalidArg "yobj" "cannot compare values of different types"
Expand Down
10 changes: 9 additions & 1 deletion tests/Paket.Tests/FilterVersionSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,12 @@ let ``prerelase version of same version is in range``() =
"1.2.3-alpha001" |> isInRange (DependenciesFileParser.parseVersionRequirement "> 1.2.3 prerelease") |> shouldEqual false
"1.0.11" |> isInRange (DependenciesFileParser.parseVersionRequirement ">= 1.0 prerelease") |> shouldEqual true
"1.0.12-build0025" |> isInRange (DependenciesFileParser.parseVersionRequirement ">= 1.0 prerelease") |> shouldEqual true



[<Test>]
let ``can check if in range for prerelease range``() =
let r = VersionRange.Range(VersionRangeBound.Including, SemVer.Parse "2.0.0-prerelease", SemVer.Parse "2.0.0", VersionRangeBound.Including)
"1.0.0.3108" |> isInRangePreRelease r |> shouldEqual false
"2.0.0-unstable2" |> isInRangePreRelease r |> shouldEqual true
"2.0-unstable2" |> isInRangePreRelease r |> shouldEqual true
"2.0-alpha1" |> isInRangePreRelease r |> shouldEqual true
5 changes: 5 additions & 0 deletions tests/Paket.Tests/NugetVersionRangeParserSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ let ``can detect range version``() =
parseRange "[2.2,3]"
|> shouldEqual (VersionRange.Range(VersionRangeBound.Including, SemVer.Parse "2.2", SemVer.Parse "3", VersionRangeBound.Including))

[<Test>]
let ``can detect range version with prerelease``() =
parseRange "[2.0.0-prerelease,2.0.0]"
|> shouldEqual (VersionRange.Range(VersionRangeBound.Including, SemVer.Parse "2.0.0-prerelease", SemVer.Parse "2.0.0", VersionRangeBound.Including))

[<Test>]
let ``can detect open range version``() =
parseRange "[2.2,)"
Expand Down

0 comments on commit afbb34f

Please sign in to comment.