Skip to content

Commit

Permalink
Make add and remove idempotent - referencing #295, #279
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Oct 24, 2014
1 parent 6c6843c commit 0436f85
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions src/Paket.Core/DependenciesFile.fs
Original file line number Diff line number Diff line change
Expand Up @@ -233,14 +233,20 @@ type DependenciesFile(fileName,options,packages : PackageRequirement list, remot
DependenciesFile(fileName,options,newPackages,remoteFiles)

member this.Add(packageName,version:string) =
if this.HasPackage packageName then failwithf "%s has already package %s" Constants.DependenciesFile packageName
tracefn "Adding %s %s to paket.dependencies" packageName version
this.AddAdditionionalPackage(packageName,version)
if this.HasPackage packageName then
traceWarnfn "%s contains package %s already. ==> Ignored" Constants.DependenciesFile packageName
this
else
tracefn "Adding %s %s to paket.dependencies" packageName version
this.AddAdditionionalPackage(packageName,version)

member this.Remove(packageName) =
if not <| this.HasPackage packageName then failwithf "%s doesn't contain package %s" Constants.DependenciesFile packageName
tracefn "Removing %s from paket.dependencies" packageName
this.RemovePackage(packageName)
if this.HasPackage packageName then
tracefn "Removing %s from paket.dependencies" packageName
this.RemovePackage(packageName)
else
traceWarnfn "%s doesn't contain package %s. ==> Ignored" Constants.DependenciesFile packageName
this

override __.ToString() =
let sources =
Expand Down

0 comments on commit 0436f85

Please sign in to comment.