From df62db0fc98dd61bd3cdc03b5cd3399176e34227 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Thu, 23 Jun 2016 17:26:41 +0200 Subject: [PATCH] Show out-of-sync error message if paket.lock is not matching paket.dependencies - implements #1750 --- RELEASE_NOTES.md | 3 +- src/Paket.Core/DependencyChangeDetection.fs | 41 +++++++++++++++++++++ src/Paket.Core/RestoreProcess.fs | 7 +++- src/Paket.Core/UpdateProcess.fs | 36 ++---------------- src/Paket/Paket.fsproj | 4 +- 5 files changed, 55 insertions(+), 36 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index d474c72044..2f3314ed15 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -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 diff --git a/src/Paket.Core/DependencyChangeDetection.fs b/src/Paket.Core/DependencyChangeDetection.fs index 0749a37b22..79ef99ff15 100644 --- a/src/Paket.Core/DependencyChangeDetection.fs +++ b/src/Paket.Core/DependencyChangeDetection.fs @@ -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 \ No newline at end of file diff --git a/src/Paket.Core/RestoreProcess.fs b/src/Paket.Core/RestoreProcess.fs index 50681dcdd2..e462a27ebf 100644 --- a/src/Paket.Core/RestoreProcess.fs +++ b/src/Paket.Core/RestoreProcess.fs @@ -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 diff --git a/src/Paket.Core/UpdateProcess.fs b/src/Paket.Core/UpdateProcess.fs index 9e0edbfca8..e102231a3d 100644 --- a/src/Paket.Core/UpdateProcess.fs +++ b/src/Paket.Core/UpdateProcess.fs @@ -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 diff --git a/src/Paket/Paket.fsproj b/src/Paket/Paket.fsproj index f24bc36b97..c30797909d 100644 --- a/src/Paket/Paket.fsproj +++ b/src/Paket/Paket.fsproj @@ -51,8 +51,8 @@ D:\code\PaketKopie update -f D:\code\Paket\integrationtests\scenarios\i001117-aws\temp - update - D:\code\Paket\integrationtests\scenarios\i001442-warn-Rx\temp + restore + D:\code\paket3dotnetcoreissue 11