From ab3087d12c6d37f5aaf67d37a70dec2bae5681f0 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Thu, 22 Jan 2015 08:52:24 +0100 Subject: [PATCH] Parse open NuGet ranges - fixes #560 --- RELEASE_NOTES.md | 3 ++ src/Paket.Core/Nuspec.fs | 3 ++ tests/Paket.Tests/NuGetOData/EasyNetQ.xml | 52 +++++++++++++++++++ tests/Paket.Tests/NuGetOData/ODataSpecs.fs | 12 +++++ .../NugetVersionRangeParserSpecs.fs | 8 +++ tests/Paket.Tests/Paket.Tests.fsproj | 5 +- 6 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 tests/Paket.Tests/NuGetOData/EasyNetQ.xml diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d0ca3b6a23..c498c1d238 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +#### 0.24.2 - 22.01.2015 +* BUGFIX: Can parse open NuGet ranges in brackets - https://github.com/fsprojects/Paket/issues/560 + #### 0.24.1 - 20.01.2015 * BUGFIX: Detect `net35-client` - https://github.com/fsprojects/Paket/issues/559 * BUGFIX: Show help for `auto-restore` command - https://github.com/fsprojects/Paket/pull/558 diff --git a/src/Paket.Core/Nuspec.fs b/src/Paket.Core/Nuspec.fs index c44b32f17b..663e92e9d4 100644 --- a/src/Paket.Core/Nuspec.fs +++ b/src/Paket.Core/Nuspec.fs @@ -39,6 +39,7 @@ module NugetVersionRangeParser = let versions = text .Trim([|'['; ']';'(';')'|]) .Split([|','|], StringSplitOptions.RemoveEmptyEntries) + |> Array.filter (fun s -> String.IsNullOrWhiteSpace s |> not) |> Array.map SemVer.Parse match versions.Length with | 2 -> @@ -48,10 +49,12 @@ module NugetVersionRangeParser = match fromB, toB with | VersionRangeBound.Excluding, VersionRangeBound.Including -> Maximum(versions.[0]) | VersionRangeBound.Excluding, VersionRangeBound.Excluding -> LessThan(versions.[0]) + | VersionRangeBound.Including, VersionRangeBound.Including -> Maximum(versions.[0]) | _ -> failParse() else match fromB, toB with | VersionRangeBound.Excluding, VersionRangeBound.Excluding -> GreaterThan(versions.[0]) + | VersionRangeBound.Including, VersionRangeBound.Including -> Minimum(versions.[0]) | _ -> failParse() | _ -> failParse() VersionRequirement(parseRange text,PreReleaseStatus.No) diff --git a/tests/Paket.Tests/NuGetOData/EasyNetQ.xml b/tests/Paket.Tests/NuGetOData/EasyNetQ.xml new file mode 100644 index 0000000000..4f8f8a9404 --- /dev/null +++ b/tests/Paket.Tests/NuGetOData/EasyNetQ.xml @@ -0,0 +1,52 @@ + + + https://www.nuget.org/api/v2/Packages + Packages + 2015-01-22T07:32:36Z + + + https://www.nuget.org/api/v2/Packages(Id='EasyNetQ',Version='0.40.3.352') + + + EasyNetQ + + 2015-01-22T07:27:48Z + + Mike Hadlow, Contributors (see GitHub repo) + + + + + 0.40.3.352 + 0.40.3.352 + Copyright Mike Hadlow 2014 + 2015-01-20T19:05:57.327 + RabbitMQ.Client:[3.4.3, ]: + EasyNetQ is a simple, opinionated .NET API for RabbitMQ + 90272 + https://www.nuget.org/packages/EasyNetQ/0.40.3.352 + https://raw.github.com/mikehadlow/EasyNetQ/gh-pages/design/logo_design.png + true + true + false + + 2015-01-20T19:05:57.327 + ckHgx6QNlrqvnf52rJLSBVh9NmHOlyAjTioVKEjd2n2UW0crKAeDkL+HgMBwja+xGH8aS+H1D0k3DbAwvT0gEg== + SHA512 + 439644 + http://easynetq.com/ + https://www.nuget.org/package/ReportAbuse/EasyNetQ/0.40.3.352 + + false + + RabbitMQ Messaging AMQP + EasyNetQ + 86 + + + https://github.com/mikehadlow/EasyNetQ/blob/master/licence.txt + + + + + \ No newline at end of file diff --git a/tests/Paket.Tests/NuGetOData/ODataSpecs.fs b/tests/Paket.Tests/NuGetOData/ODataSpecs.fs index 93b3e1298d..f208c632b6 100644 --- a/tests/Paket.Tests/NuGetOData/ODataSpecs.fs +++ b/tests/Paket.Tests/NuGetOData/ODataSpecs.fs @@ -39,6 +39,18 @@ let ``can detect explicit dependencies for Rx-PlaformServices``() = CacheVersion = NugetPackageCache.CurrentCacheVersion SourceUrl = fakeUrl } +[] +let ``can detect explicit dependencies for EasyNetQ``() = + parse "NuGetOData/EasyNetQ.xml" + |> shouldEqual + { PackageName = "EasyNetQ" + DownloadUrl = "https://www.nuget.org/api/v2/package/EasyNetQ/0.40.3.352" + Dependencies = + [PackageName "RabbitMQ.Client",DependenciesFileParser.parseVersionRequirement(">= 3.4.3"), []] + Unlisted = false + CacheVersion = NugetPackageCache.CurrentCacheVersion + SourceUrl = fakeUrl } + [] let ``can detect explicit dependencies for Fleece``() = parse "NuGetOData/Fleece.xml" diff --git a/tests/Paket.Tests/NugetVersionRangeParserSpecs.fs b/tests/Paket.Tests/NugetVersionRangeParserSpecs.fs index 48a880cbd1..028e8a317c 100644 --- a/tests/Paket.Tests/NugetVersionRangeParserSpecs.fs +++ b/tests/Paket.Tests/NugetVersionRangeParserSpecs.fs @@ -46,6 +46,14 @@ let ``can detect range version``() = parseRange "[2.2,3]" |> shouldEqual (VersionRange.Range(VersionRangeBound.Including, SemVer.Parse "2.2", SemVer.Parse "3", VersionRangeBound.Including)) +[] +let ``can detect open range version``() = + parseRange "[2.2,]" + |> shouldEqual (VersionRange.Minimum (SemVer.Parse "2.2")) + parseRange "[2.2, ]" + |> shouldEqual (VersionRange.Minimum (SemVer.Parse "2.2")) + parseRange "[,2.2]" + |> shouldEqual (VersionRange.Maximum (SemVer.Parse "2.2")) [] let ``can detect "null" version``() = diff --git a/tests/Paket.Tests/Paket.Tests.fsproj b/tests/Paket.Tests/Paket.Tests.fsproj index 73a7894275..2dacde9d63 100644 --- a/tests/Paket.Tests/Paket.Tests.fsproj +++ b/tests/Paket.Tests/Paket.Tests.fsproj @@ -1,4 +1,4 @@ - + @@ -137,6 +137,9 @@ Always + + Always + Always