From cc0fdb51972a1e3795aeff5f7b692b7080a74abe Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Wed, 19 Nov 2014 13:49:17 +0100 Subject: [PATCH] BUGFIX: Read sources even when we don't find packages - #372 --- RELEASE_NOTES.md | 3 +++ src/Paket.Core/DependenciesFile.fs | 20 +++++++------------ src/Paket.Core/FindOutdated.fs | 2 +- src/Paket.Core/NugetConvert.fs | 2 +- src/Paket.Core/Simplifier.fs | 2 +- src/Paket/Paket.fsproj | 4 ++-- .../DependenciesFile/ParserSpecs.fs | 12 +++++++++++ 7 files changed, 27 insertions(+), 18 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index f40f0a3793..e0df75ac39 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,3 +1,6 @@ +#### 0.15.2 - 19.11.2014 +* BUGFIX: Read sources even when we don't find packages - https://github.com/fsprojects/Paket/issues/372 + #### 0.15.1 - 19.11.2014 * Always control framework assemblies diff --git a/src/Paket.Core/DependenciesFile.fs b/src/Paket.Core/DependenciesFile.fs index c00f5101f5..0ce4b8fd91 100644 --- a/src/Paket.Core/DependenciesFile.fs +++ b/src/Paket.Core/DependenciesFile.fs @@ -180,9 +180,10 @@ module DependenciesFileParser = with | exn -> failwithf "Error in paket.dependencies line %d%s %s" lineNo Environment.NewLine exn.Message) - |> fun (_,options,_,packages,remoteFiles) -> + |> fun (_,options,sources,packages,remoteFiles) -> fileName, options, + sources, packages |> List.rev, remoteFiles |> List.rev @@ -213,16 +214,9 @@ module DependenciesFileSerializer = if text <> "" && preReleases <> "" then text + " " + preReleases else text + preReleases /// Allows to parse and analyze paket.dependencies files. -type DependenciesFile(fileName,options,packages : PackageRequirement list, remoteFiles : UnresolvedSourceFile list) = +type DependenciesFile(fileName,options,sources,packages : PackageRequirement list, remoteFiles : UnresolvedSourceFile list) = let packages = packages |> Seq.toList let dependencyMap = Map.ofSeq (packages |> Seq.map (fun p -> p.Name, p.VersionRequirement)) - - let sources = - packages - |> Seq.map (fun p -> p.Sources) - |> Seq.concat - |> Set.ofSeq - |> Set.toList member __.DirectDependencies = dependencyMap member __.Packages = packages @@ -272,7 +266,7 @@ type DependenciesFile(fileName,options,packages : PackageRequirement list, remot FrameworkRestriction = None Parent = PackageRequirementSource.DependenciesFile fileName } - DependenciesFile(fileName,options,packages @ [newPackage], remoteFiles) + DependenciesFile(fileName,options,sources,packages @ [newPackage], remoteFiles) member __.AddFixedPackage(packageName:PackageName,version:string) = let versionRange = DependenciesFileParser.parseVersionRequirement (version.Trim '!') @@ -294,14 +288,14 @@ type DependenciesFile(fileName,options,packages : PackageRequirement list, remot FrameworkRestriction = None Parent = PackageRequirementSource.DependenciesFile fileName } - DependenciesFile(fileName,options,(packages |> List.filter (fun p -> NormalizedPackageName p.Name <> NormalizedPackageName packageName)) @ [newPackage], remoteFiles) + DependenciesFile(fileName,options,sources,(packages |> List.filter (fun p -> NormalizedPackageName p.Name <> NormalizedPackageName packageName)) @ [newPackage], remoteFiles) member __.RemovePackage(packageName:PackageName) = let newPackages = packages |> List.filter (fun p -> NormalizedPackageName p.Name <> NormalizedPackageName packageName) - DependenciesFile(fileName,options,newPackages,remoteFiles) + DependenciesFile(fileName,options,sources,newPackages,remoteFiles) member this.Add(packageName,version:string) = let (PackageName name) = packageName @@ -334,7 +328,7 @@ type DependenciesFile(fileName,options,packages : PackageRequirement list, remot if NormalizedPackageName p.Name = NormalizedPackageName packageName then { p with VersionRequirement = versionRequirement } else p) - DependenciesFile(this.FileName, this.Options, packages, this.RemoteFiles) + DependenciesFile(this.FileName, this.Options, sources, packages, this.RemoteFiles) else traceWarnfn "%s doesn't contain package %s. ==> Ignored" fileName name this diff --git a/src/Paket.Core/FindOutdated.fs b/src/Paket.Core/FindOutdated.fs index 4155ad4b7d..55284042a0 100644 --- a/src/Paket.Core/FindOutdated.fs +++ b/src/Paket.Core/FindOutdated.fs @@ -23,7 +23,7 @@ let FindOutdated(dependenciesFileName, strict,includingPrereleases) = | false,false -> VersionRequirement.AllReleases { p with VersionRequirement = requirement}) - DependenciesFile(loadedFile.FileName,loadedFile.Options,newPackages,loadedFile.RemoteFiles) + DependenciesFile(loadedFile.FileName,loadedFile.Options,loadedFile.Sources,newPackages,loadedFile.RemoteFiles) let resolution = dependenciesFile.Resolve(true) let resolvedPackages = resolution.ResolvedPackages.GetModelOrFail() diff --git a/src/Paket.Core/NugetConvert.fs b/src/Paket.Core/NugetConvert.fs index 53fd44a956..824efeaae1 100644 --- a/src/Paket.Core/NugetConvert.fs +++ b/src/Paket.Core/NugetConvert.fs @@ -149,7 +149,7 @@ let private convertNugetsToDepFile(dependenciesFilename,nugetPackagesConfigs, so match existingDepFile with | None -> let packages = packagesToAdd |> List.map (fun (name,v) -> nugetPackageRequirement(name,v)) - DependenciesFile(dependenciesFilename, InstallOptions.Default, packages, []).Save() + DependenciesFile(dependenciesFilename, InstallOptions.Default, sources, packages, []).Save() | Some depFile -> if not (packagesToAdd |> List.isEmpty) then (packagesToAdd |> List.fold (fun (d : DependenciesFile) (name,version) -> d.Add(PackageName name,version)) depFile).Save() diff --git a/src/Paket.Core/Simplifier.fs b/src/Paket.Core/Simplifier.fs index 4002e8be15..4dec8f1a49 100644 --- a/src/Paket.Core/Simplifier.fs +++ b/src/Paket.Core/Simplifier.fs @@ -52,7 +52,7 @@ let Analyze(allPackages : list, depFile : DependenciesFile, ref else refFiles |> List.map (fun refFile -> {refFile with NugetPackages = refFile.NugetPackages |> getSimplifiedDeps id refFile.FileName}) - DependenciesFile(depFile.FileName, depFile.Options, simplifiedDeps, depFile.RemoteFiles), refFiles' + DependenciesFile(depFile.FileName, depFile.Options, depFile.Sources, simplifiedDeps, depFile.RemoteFiles), refFiles' let Simplify (dependenciesFileName,interactive) = if not <| File.Exists dependenciesFileName then diff --git a/src/Paket/Paket.fsproj b/src/Paket/Paket.fsproj index e75701ef76..1f60b78960 100644 --- a/src/Paket/Paket.fsproj +++ b/src/Paket/Paket.fsproj @@ -26,12 +26,12 @@ 3 - update -f + add nuget Newtonsoft.Json Project paket.exe - D:\code\Paket09x + D:\code\Paket-dependencies pdbonly diff --git a/tests/Paket.Tests/DependenciesFile/ParserSpecs.fs b/tests/Paket.Tests/DependenciesFile/ParserSpecs.fs index aa07a2c307..1c49d36408 100644 --- a/tests/Paket.Tests/DependenciesFile/ParserSpecs.fs +++ b/tests/Paket.Tests/DependenciesFile/ParserSpecs.fs @@ -16,6 +16,18 @@ let ``should read emptx config``() = cfg.Packages.Length |> shouldEqual 0 cfg.RemoteFiles.Length |> shouldEqual 0 +let configWithSourceOnly = """ +source http://nuget.org/api/v2 +""" + +[] +let ``should read config which only contains a source``() = + let cfg = DependenciesFile.FromCode(configWithSourceOnly) + cfg.Options.Strict |> shouldEqual false + + cfg.Sources.Length |> shouldEqual 1 + cfg.Sources.Head |> shouldEqual (Nuget({ Url = "http://nuget.org/api/v2"; Authentication = None })) + let config1 = """ source "http://nuget.org/api/v2"