Skip to content

Commit

Permalink
BUGFIX: Read sources even when we don't find packages - #372
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Nov 19, 2014
1 parent 48851c5 commit cc0fdb5
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 18 deletions.
3 changes: 3 additions & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
20 changes: 7 additions & 13 deletions src/Paket.Core/DependenciesFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 '!')
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/FindOutdated.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/NugetConvert.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/Simplifier.fs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ let Analyze(allPackages : list<ResolvedPackage>, 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
Expand Down
4 changes: 2 additions & 2 deletions src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,12 @@
<WarningLevel>3</WarningLevel>
<DocumentationFile>
</DocumentationFile>
<StartArguments>update -f</StartArguments>
<StartArguments>add nuget Newtonsoft.Json</StartArguments>
<StartAction>Project</StartAction>
<StartProgram>paket.exe</StartProgram>
<StartWorkingDirectory>
</StartWorkingDirectory>
<StartWorkingDirectory>D:\code\Paket09x</StartWorkingDirectory>
<StartWorkingDirectory>D:\code\Paket-dependencies</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down
12 changes: 12 additions & 0 deletions tests/Paket.Tests/DependenciesFile/ParserSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -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
"""

[<Test>]
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"
Expand Down

0 comments on commit cc0fdb5

Please sign in to comment.