From da89bfa81ebb4cb41ed293bed63b31c4be67a6d1 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Thu, 13 Aug 2015 10:51:06 +0200 Subject: [PATCH] Version range semantics changed for >= x.y.z prerelease - closes #976 --- RELEASE_NOTES.md | 5 ++--- src/Paket.Core/VersionRange.fs | 12 +++++++++-- tests/Paket.Tests/FilterVersionSpecs.fs | 7 +++++++ .../Resolver/SimpleDependenciesSpecs.fs | 20 ++++++++++++++++++- 4 files changed, 38 insertions(+), 6 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 59013e3eed..3ddbc2af40 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,7 +1,6 @@ -#### 1.26.2 - 12.08.2015 +#### 1.27.0 - 13.08.2015 +* Version range semantics changed for `>= x.y.z prerelease` - https://github.com/fsprojects/Paket/issues/976 * BUGFIX: Version trace got lost - https://twitter.com/indy9000/status/631201649219010561 - -#### 1.26.1 - 11.08.2015 * BUGFIX: copy_local behaviour was broken - https://github.com/fsprojects/Paket/issues/972 #### 1.26.0 - 10.08.2015 diff --git a/src/Paket.Core/VersionRange.fs b/src/Paket.Core/VersionRange.fs index d61ae55d56..13598de87d 100644 --- a/src/Paket.Core/VersionRange.fs +++ b/src/Paket.Core/VersionRange.fs @@ -108,10 +108,18 @@ type VersionRequirement = | None -> true | Some pre -> List.exists ((=) pre.Name) list + let sameVersionWithoutPreRelease v = + let sameVersion = + match v.PreRelease with + | None -> v.Major = version.Major && v.Minor = version.Minor && v.Patch = version.Patch && v.Build = version.Build + | _ -> false + + prerelease <> PreReleaseStatus.No && sameVersion && checkPrerelease prerelease version + match range with - | Specific v -> v = version + | Specific v -> v = version || sameVersionWithoutPreRelease v | OverrideAll v -> v = version - | Minimum v -> v = version || (v <= version && checkPrerelease prerelease version) + | Minimum v -> v = version || (v <= version && checkPrerelease prerelease version) || sameVersionWithoutPreRelease v | GreaterThan v -> v < version && checkPrerelease prerelease version | Maximum v -> v = version || (v >= version && checkPrerelease prerelease version) | LessThan v -> v > version && checkPrerelease prerelease version diff --git a/tests/Paket.Tests/FilterVersionSpecs.fs b/tests/Paket.Tests/FilterVersionSpecs.fs index 2fb7f2bdcc..e4973fb855 100644 --- a/tests/Paket.Tests/FilterVersionSpecs.fs +++ b/tests/Paket.Tests/FilterVersionSpecs.fs @@ -101,4 +101,11 @@ let ``can support rc version``() = [] let ``can support "build" version``() = "0.9.0-build06428" |> isInRange (DependenciesFileParser.parseVersionRequirement ">= 0.9.0-build06428") |> shouldEqual true + + +[] +let ``prerelase version of same version is in range``() = + "1.2.3-alpha001" |> isInRange (DependenciesFileParser.parseVersionRequirement ">= 1.2.3 prerelease") |> shouldEqual true + "1.2.3-alpha001" |> isInRange (DependenciesFileParser.parseVersionRequirement "1.2.3 prerelease") |> shouldEqual true + "1.2.3-alpha001" |> isInRange (DependenciesFileParser.parseVersionRequirement "> 1.2.3 prerelease") |> shouldEqual false \ No newline at end of file diff --git a/tests/Paket.Tests/Resolver/SimpleDependenciesSpecs.fs b/tests/Paket.Tests/Resolver/SimpleDependenciesSpecs.fs index 6b71f33d4a..a1ced0d972 100644 --- a/tests/Paket.Tests/Resolver/SimpleDependenciesSpecs.fs +++ b/tests/Paket.Tests/Resolver/SimpleDependenciesSpecs.fs @@ -99,4 +99,22 @@ let ``should resolve fixed config4``() = let resolved = cfg.Resolve(noSha1,VersionsFromGraph graph3, PackageDetailsFromGraph graph3).ResolvedPackages.GetModelOrFail() getVersion resolved.[NormalizedPackageName (PackageName "Castle.Core")] |> shouldEqual "3.2.0" getVersion resolved.[NormalizedPackageName (PackageName "Castle.Windsor-log4net")] |> shouldEqual "3.2.0.1" - getVersion resolved.[NormalizedPackageName (PackageName "Castle.Core-log4net")] |> shouldEqual "3.2.0" \ No newline at end of file + getVersion resolved.[NormalizedPackageName (PackageName "Castle.Core-log4net")] |> shouldEqual "3.2.0" + +let config5 = """ +source "http://nuget.org/api/v2" + +nuget Microsoft.AspNet.Mvc >= 6.0.0 prerelease +""" + +let graph5 = [ + "Microsoft.AspNet.Mvc","6.0.0-beta6",[] + "Microsoft.AspNet.Mvc","6.0.0-beta1",[] + "Microsoft.AspNet.Mvc","5.2.3",[] +] + +[] +let ``should resolve prerelease config``() = + let cfg = DependenciesFile.FromCode(config5) + let resolved = cfg.Resolve(noSha1,VersionsFromGraph graph5, PackageDetailsFromGraph graph5).ResolvedPackages.GetModelOrFail() + getVersion resolved.[NormalizedPackageName (PackageName "Microsoft.AspNet.Mvc")] |> shouldEqual "6.0.0-beta6" \ No newline at end of file