Skip to content

Commit

Permalink
Show out-of-sync error message if paket.lock is not matching paket.de…
Browse files Browse the repository at this point in the history
…pendencies - implements #1750
  • Loading branch information
forki committed Jun 23, 2016
1 parent 7413053 commit df62db0
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 36 deletions.
3 changes: 2 additions & 1 deletion RELEASE_NOTES.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#### 3.2.0-alpha002 - 23.06.2016
#### 3.2.0-alpha003 - 23.06.2016
* Show out-of-sync error message if paket.lock is not matching paket.dependencies - https://github.com/fsprojects/Paket/issues/1750
* BUGFIX: Don't report warnings for packages that are not installed for current target framework - https://github.com/fsprojects/Paket/issues/1693
* BUGFIX: Runtime deps are copied based on TargetFramework - https://github.com/fsprojects/Paket/issues/1751
* BUGFIX: Do not take over control over manual nodes - https://github.com/fsprojects/Paket/issues/1746
Expand Down
41 changes: 41 additions & 0 deletions src/Paket.Core/DependencyChangeDetection.fs
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,44 @@ let GetPreferredNuGetVersions (dependenciesFile:DependenciesFile,lockFile:LockFi
| Some s -> kv.Key, (kv.Value.Version, s)
| None -> kv.Key, (kv.Value.Version, kv.Value.Source))
|> Map.ofSeq

let GetChanges(dependenciesFile,lockFile) =
let nuGetChanges = findNuGetChangesInDependenciesFile(dependenciesFile,lockFile)
let nuGetChangesPerGroup =
nuGetChanges
|> Seq.groupBy fst
|> Map.ofSeq

let remoteFileChanges = findRemoteFileChangesInDependenciesFile(dependenciesFile,lockFile)
let remoteFileChangesPerGroup =
remoteFileChanges
|> Seq.groupBy fst
|> Map.ofSeq

let hasNuGetChanges groupName =
match nuGetChangesPerGroup |> Map.tryFind groupName with
| None -> false
| Some x -> Seq.isEmpty x |> not

let hasRemoteFileChanges groupName =
match remoteFileChangesPerGroup |> Map.tryFind groupName with
| None -> false
| Some x -> Seq.isEmpty x |> not

let hasChangedSettings groupName =
match dependenciesFile.Groups |> Map.tryFind groupName with
| None -> true
| Some dependenciesFileGroup ->
match lockFile.Groups |> Map.tryFind groupName with
| None -> true
| Some lockFileGroup -> dependenciesFileGroup.Options <> lockFileGroup.Options

let hasChanges groupName _ = hasChangedSettings groupName || hasNuGetChanges groupName || hasRemoteFileChanges groupName

let hasAnyChanges =
dependenciesFile.Groups
|> Map.filter hasChanges
|> Map.isEmpty
|> not

hasAnyChanges,nuGetChanges,remoteFileChanges,hasChanges
7 changes: 6 additions & 1 deletion src/Paket.Core/RestoreProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,12 @@ let Restore(dependenciesFileName,force,group,referencesFileNames) =
let lockFile =
LockFile.LoadFrom(lockFileName.FullName)
|> LocalFile.overrideLockFile localFile


let hasAnyChanges,_,_,_ = DependencyChangeDetection.GetChanges(dependenciesFile,lockFile)

if hasAnyChanges then
failwithf "paket.dependencies and paket.lock are out of sync in %s.%sPlease run 'paket install' or 'paket update' to recompute the paket.lock file." lockFileName.Directory.FullName Environment.NewLine

let groups =
match group with
| None -> lockFile.Groups
Expand Down
36 changes: 4 additions & 32 deletions src/Paket.Core/UpdateProcess.fs
Original file line number Diff line number Diff line change
Expand Up @@ -85,38 +85,10 @@ let selectiveUpdate force getSha1 getSortedVersionsF getPackageDetailsF (lockFil

changes,groups
| Install ->
let nuGetChanges = DependencyChangeDetection.findNuGetChangesInDependenciesFile(dependenciesFile,lockFile)
let nuGetChangesPerGroup =
nuGetChanges
|> Seq.groupBy fst
|> Map.ofSeq

let remoteFileChanges = DependencyChangeDetection.findRemoteFileChangesInDependenciesFile(dependenciesFile,lockFile)
let remoteFileChangesPerGroup =
remoteFileChanges
|> Seq.groupBy fst
|> Map.ofSeq

let hasNuGetChanges groupName =
match nuGetChangesPerGroup |> Map.tryFind groupName with
| None -> false
| Some x -> Seq.isEmpty x |> not

let hasRemoteFileChanges groupName =
match remoteFileChangesPerGroup |> Map.tryFind groupName with
| None -> false
| Some x -> Seq.isEmpty x |> not

let hasChangedSettings groupName =
match dependenciesFile.Groups |> Map.tryFind groupName with
| None -> true
| Some dependenciesFileGroup ->
match lockFile.Groups |> Map.tryFind groupName with
| None -> true
| Some lockFileGroup -> dependenciesFileGroup.Options <> lockFileGroup.Options

let hasChanges groupName _ =
let hasChanges = hasChangedSettings groupName || hasNuGetChanges groupName || hasRemoteFileChanges groupName
let hasAnyChanges,nuGetChanges,remoteFileChanges,hasChanges = DependencyChangeDetection.GetChanges(dependenciesFile,lockFile)

let hasChanges groupName x =
let hasChanges = hasChanges groupName x
if not hasChanges then
tracefn "Skipping resolver for group %O since it is already up-to-date" groupName
hasChanges
Expand Down
4 changes: 2 additions & 2 deletions src/Paket/Paket.fsproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
<StartWorkingDirectory>D:\code\PaketKopie</StartWorkingDirectory>
<StartArguments>update -f</StartArguments>
<StartWorkingDirectory>D:\code\Paket\integrationtests\scenarios\i001117-aws\temp</StartWorkingDirectory>
<StartArguments>update</StartArguments>
<StartWorkingDirectory>D:\code\Paket\integrationtests\scenarios\i001442-warn-Rx\temp</StartWorkingDirectory>
<StartArguments>restore</StartArguments>
<StartWorkingDirectory>D:\code\paket3dotnetcoreissue</StartWorkingDirectory>
</PropertyGroup>
<PropertyGroup>
<MinimumVisualStudioVersion Condition="'$(MinimumVisualStudioVersion)' == ''">11</MinimumVisualStudioVersion>
Expand Down

0 comments on commit df62db0

Please sign in to comment.