Skip to content

Commit

Permalink
Paket update nuget X doesn't work - fixes #512
Browse files Browse the repository at this point in the history
  • Loading branch information
forki committed Jan 5, 2015
1 parent cf118eb commit 468aa9c
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 25 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.21.6 - 05.01.2015
* BUGFIX: Paket update nuget X doesn't work - https://github.com/fsprojects/Paket/issues/512

#### 0.21.5 - 03.01.2015
* Always trim line end in lockfile

Expand Down
10 changes: 5 additions & 5 deletions paket.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ NUGET
remote: https://nuget.org/api/v2
specs:
DotNetZip (1.9.3)
FAKE (3.12.2)
FAKE (3.13.1)
FSharp.Compiler.Service (0.0.81)
FSharp.Core (3.1.2.1)
FSharp.Formatting (2.4.38)
FSharp.Formatting (2.5.0)
FSharp.Compiler.Service (>= 0.0.81)
Microsoft.AspNet.Razor (2.0.30506)
RazorEngine (3.3.0)
Expand All @@ -20,8 +20,8 @@ NUGET
NuGet.CommandLine (2.8.3)
NUnit (2.6.4)
NUnit.Runners (2.6.4)
Octokit (0.6.1)
Microsoft.Net.Http
Octokit (0.6.2)
Microsoft.Net.Http
RazorEngine (3.3.0)
Microsoft.AspNet.Razor (>= 2.0.30506.0)
UnionArgParser (0.8.2)
Expand All @@ -31,7 +31,7 @@ GITHUB
FsUnit.fs (a8830b5a70e72a1948592cfa1e43e3c5b0a31b92)
remote: fsharp/FAKE
specs:
modules/Octokit/Octokit.fsx (875c384b04eb7cdee601b8c99852bba2d5e2142b)
modules/Octokit/Octokit.fsx (e24641b3214caf51154f0bfb12f639ebfdf68bdf)
Octokit
remote: nessos/Streams
specs:
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/AddProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ let Add(dependenciesFileName, package, version, force, hard, interactive, instal

dependenciesFile.Save()

let lockFile = UpdateProcess.SelectiveUpdate(dependenciesFile,force)
let lockFile = UpdateProcess.SelectiveUpdate(dependenciesFile,Some(NormalizedPackageName package),force)

if interactive then
for project in ProjectFile.FindAllProjects(Path.GetDirectoryName lockFile.FileName) do
Expand Down
4 changes: 1 addition & 3 deletions src/Paket.Core/DependencyChangeDetection.fs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ let findChangesInDependenciesFile(dependenciesFile:DependenciesFile,lockFile:Loc
added
|> Set.union modified

let PinUnchangedDependencies (dependenciesFile:DependenciesFile) (oldLockFile:LockFile) =
let changedDependencies = findChangesInDependenciesFile(dependenciesFile,oldLockFile)

let PinUnchangedDependencies (dependenciesFile:DependenciesFile) (oldLockFile:LockFile) (changedDependencies:Set<NormalizedPackageName>) =
oldLockFile.ResolvedPackages
|> Seq.map (fun kv -> kv.Value)
|> Seq.filter (fun p -> not <| changedDependencies.Contains(NormalizedPackageName p.Name))
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/PublicAPI.fs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ type Dependencies(dependenciesFileName: string) =
member this.Install(force: bool,hard: bool,withBindingRedirects:bool): unit =
Utils.RunInLockedAccessMode(
this.RootPath,
fun () -> UpdateProcess.SmartInstall(dependenciesFileName,force,hard,withBindingRedirects))
fun () -> UpdateProcess.SmartInstall(dependenciesFileName,None,force,hard,withBindingRedirects))

/// Installs all dependencies.
member this.Install(force: bool,hard: bool): unit = this.Install(force,hard,false)
Expand Down
2 changes: 1 addition & 1 deletion src/Paket.Core/RemoveProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ let Remove(dependenciesFileName, package:PackageName, force, hard, interactive,

dependenciesFile.Save()

UpdateProcess.SelectiveUpdate(dependenciesFile,force)
UpdateProcess.SelectiveUpdate(dependenciesFile,None,force)

if installAfter then
let sources = DependenciesFile.ReadFromFile(dependenciesFileName).GetAllPackageSources()
Expand Down
18 changes: 12 additions & 6 deletions src/Paket.Core/UpdateProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -39,29 +39,35 @@ let addPackagesFromReferenceFiles projects (dependenciesFile:DependenciesFile) =
newDependenciesFile.Save()
newDependenciesFile

let SelectiveUpdate(dependenciesFile:DependenciesFile, force) =
let SelectiveUpdate(dependenciesFile:DependenciesFile, exclude, force) =
let lockFileName = DependenciesFile.FindLockfile dependenciesFile.FileName

if not lockFileName.Exists then
let resolution = dependenciesFile.Resolve(force)
LockFile.Create(lockFileName.FullName, dependenciesFile.Options, resolution.ResolvedPackages, resolution.ResolvedSourceFiles)
else
let oldLockFile = LockFile.LoadFrom(lockFileName.FullName)
let changedDependencies = DependencyChangeDetection.findChangesInDependenciesFile(dependenciesFile,oldLockFile)

let dependenciesFile = DependencyChangeDetection.PinUnchangedDependencies dependenciesFile oldLockFile
let changed =
match exclude with
| None -> changedDependencies
| Some package -> Set.add package changedDependencies

let dependenciesFile = DependencyChangeDetection.PinUnchangedDependencies dependenciesFile oldLockFile changed

let resolution = dependenciesFile.Resolve(force)
LockFile.Create(lockFileName.FullName, dependenciesFile.Options, resolution.ResolvedPackages, oldLockFile.SourceFiles)

/// Smart install command
let SmartInstall(dependenciesFileName, force, hard, withBindingRedirects) =
let SmartInstall(dependenciesFileName, exclude, force, hard, withBindingRedirects) =
let root = Path.GetDirectoryName dependenciesFileName
let projects = InstallProcess.findAllReferencesFiles(root)
let dependenciesFile =
DependenciesFile.ReadFromFile(dependenciesFileName)
|> addPackagesFromReferenceFiles projects

let lockFile = SelectiveUpdate(dependenciesFile,force)
let lockFile = SelectiveUpdate(dependenciesFile,exclude,force)

InstallProcess.InstallIntoProjects(
dependenciesFile.GetAllPackageSources(),
Expand All @@ -80,12 +86,12 @@ let UpdatePackage(dependenciesFileName, packageName : PackageName, newVersion, f
.Save()
| None -> ()

SmartInstall(dependenciesFileName,force,hard,withBindingRedirects)
SmartInstall(dependenciesFileName,Some(NormalizedPackageName packageName),force,hard,withBindingRedirects)

/// Update command
let Update(dependenciesFileName, force, hard, withBindingRedirects) =
let lockFileName = DependenciesFile.FindLockfile dependenciesFileName
if lockFileName.Exists then
lockFileName.Delete()

SmartInstall(dependenciesFileName,force,hard,withBindingRedirects)
SmartInstall(dependenciesFileName,None,force,hard,withBindingRedirects)
4 changes: 2 additions & 2 deletions src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
<DocumentationFile>
</DocumentationFile>
<StartArguments>update -f</StartArguments>
<StartArguments>install --log-file "C:\temp\log.txt"</StartArguments>
<StartArguments>update nuget JsonLd.Entities</StartArguments>
<StartAction>Project</StartAction>
<StartProgram>paket.exe</StartProgram>
<StartWorkingDirectory>
</StartWorkingDirectory>
<StartWorkingDirectory>c:\code\paketkopie</StartWorkingDirectory>
<StartWorkingDirectory>d:\code\paketkopie</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>pdbonly</DebugType>
Expand Down
15 changes: 9 additions & 6 deletions tests/Paket.Tests/DependenciesFile/DependencyChangesSpecs.fs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ nuget Castle.Windsor-log4net"""
let cfg = DependenciesFile.FromCode(after)
let lockFile = LockFile.Parse("",toLines lockFileData)

let newDependencies = DependencyChangeDetection.PinUnchangedDependencies cfg lockFile
let changedDependencies = DependencyChangeDetection.findChangesInDependenciesFile(cfg,lockFile)
let newDependencies = DependencyChangeDetection.PinUnchangedDependencies cfg lockFile changedDependencies
newDependencies.DirectDependencies
|> shouldEqual Map.empty

Expand Down Expand Up @@ -70,8 +71,9 @@ nuget NUnit"""

let cfg = DependenciesFile.FromCode(after)
let lockFile = LockFile.Parse("",toLines lockFileData)
let changedDependencies = DependencyChangeDetection.findChangesInDependenciesFile(cfg,lockFile)

let newDependencies = DependencyChangeDetection.PinUnchangedDependencies cfg lockFile
let newDependencies = DependencyChangeDetection.PinUnchangedDependencies cfg lockFile changedDependencies
let expected =
Map.ofList
([(PackageName "Castle.Core", VersionRequirement (Specific(SemVer.Parse "3.3.3"),No));
Expand Down Expand Up @@ -116,8 +118,9 @@ nuget Castle.Windsor-log4net >= 3.3.0"""

let cfg = DependenciesFile.FromCode(after)
let lockFile = LockFile.Parse("",toLines lockFileData)
let changedDependencies = DependencyChangeDetection.findChangesInDependenciesFile(cfg,lockFile)

let newDependencies = DependencyChangeDetection.PinUnchangedDependencies cfg lockFile
let newDependencies = DependencyChangeDetection.PinUnchangedDependencies cfg lockFile changedDependencies
let expected =
Map.ofList
([(PackageName "Castle.Core", VersionRequirement (Specific(SemVer.Parse "3.3.3"),No));
Expand Down Expand Up @@ -161,13 +164,13 @@ nuget Castle.Windsor-log4net >= 3.4.0"""

let cfg = DependenciesFile.FromCode(after)
let lockFile = LockFile.Parse("",toLines lockFileData)
let changedDependencies = DependencyChangeDetection.findChangesInDependenciesFile(cfg,lockFile)

let newDependencies = DependencyChangeDetection.PinUnchangedDependencies cfg lockFile
let newDependencies = DependencyChangeDetection.PinUnchangedDependencies cfg lockFile changedDependencies
let expected =
Map.ofList
([(PackageName "Castle.Windsor-log4net", VersionRequirement (Minimum(SemVer.Parse "3.4.0"),No));])


newDependencies.DirectDependencies
|> shouldEqual expected

|> shouldEqual expected

0 comments on commit 468aa9c

Please sign in to comment.