From fe14f955212b8a74e18b886da2f2a3893e7202e2 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Thu, 23 Jun 2016 17:36:13 +0200 Subject: [PATCH] Show out-of-sync error message if paket.lock is not matching paket.dependencies - implements #1750 --- RELEASE_NOTES.md | 2 +- src/Paket.Core/DependencyChangeDetection.fs | 14 ++++++++++---- src/Paket.Core/RestoreProcess.fs | 2 +- src/Paket.Core/UpdateProcess.fs | 2 +- .../DependenciesFile/DependencyChangesSpecs.fs | 14 +++++++------- 5 files changed, 20 insertions(+), 14 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 2f3314ed15..7eb04b85da 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,4 +1,4 @@ -#### 3.2.0-alpha003 - 23.06.2016 +#### 3.2.0-alpha004 - 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 diff --git a/src/Paket.Core/DependencyChangeDetection.fs b/src/Paket.Core/DependencyChangeDetection.fs index 79ef99ff15..79b37d20eb 100644 --- a/src/Paket.Core/DependencyChangeDetection.fs +++ b/src/Paket.Core/DependencyChangeDetection.fs @@ -4,7 +4,7 @@ open Paket.Domain open Paket.Requirements open Paket.PackageResolver -let findNuGetChangesInDependenciesFile(dependenciesFile:DependenciesFile,lockFile:LockFile) = +let findNuGetChangesInDependenciesFile(dependenciesFile:DependenciesFile,lockFile:LockFile,strict) = let allTransitives groupName = lockFile.GetTransitiveDependencies groupName let hasChanged groupName transitives (newRequirement:PackageRequirement) (originalPackage:ResolvedPackage) = let settingsChanged() = @@ -14,7 +14,13 @@ let findNuGetChangesInDependenciesFile(dependenciesFile:DependenciesFile,lockFil else true else false - newRequirement.VersionRequirement.IsInRange originalPackage.Version |> not || settingsChanged() + let requirementOk = + if strict then + newRequirement.VersionRequirement.IsInRange originalPackage.Version + else + newRequirement.IncludingPrereleases().VersionRequirement.IsInRange originalPackage.Version + + (not requirementOk) || settingsChanged() let added groupName transitives = match dependenciesFile.Groups |> Map.tryFind groupName with @@ -176,8 +182,8 @@ let GetPreferredNuGetVersions (dependenciesFile:DependenciesFile,lockFile:LockFi | None -> kv.Key, (kv.Value.Version, kv.Value.Source)) |> Map.ofSeq -let GetChanges(dependenciesFile,lockFile) = - let nuGetChanges = findNuGetChangesInDependenciesFile(dependenciesFile,lockFile) +let GetChanges(dependenciesFile,lockFile,strict) = + let nuGetChanges = findNuGetChangesInDependenciesFile(dependenciesFile,lockFile,strict) let nuGetChangesPerGroup = nuGetChanges |> Seq.groupBy fst diff --git a/src/Paket.Core/RestoreProcess.fs b/src/Paket.Core/RestoreProcess.fs index e462a27ebf..c68ef3710e 100644 --- a/src/Paket.Core/RestoreProcess.fs +++ b/src/Paket.Core/RestoreProcess.fs @@ -129,7 +129,7 @@ let Restore(dependenciesFileName,force,group,referencesFileNames) = LockFile.LoadFrom(lockFileName.FullName) |> LocalFile.overrideLockFile localFile - let hasAnyChanges,_,_,_ = DependencyChangeDetection.GetChanges(dependenciesFile,lockFile) + let hasAnyChanges,_,_,_ = DependencyChangeDetection.GetChanges(dependenciesFile,lockFile,false) 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 diff --git a/src/Paket.Core/UpdateProcess.fs b/src/Paket.Core/UpdateProcess.fs index e102231a3d..d7c8d00705 100644 --- a/src/Paket.Core/UpdateProcess.fs +++ b/src/Paket.Core/UpdateProcess.fs @@ -85,7 +85,7 @@ let selectiveUpdate force getSha1 getSortedVersionsF getPackageDetailsF (lockFil changes,groups | Install -> - let hasAnyChanges,nuGetChanges,remoteFileChanges,hasChanges = DependencyChangeDetection.GetChanges(dependenciesFile,lockFile) + let hasAnyChanges,nuGetChanges,remoteFileChanges,hasChanges = DependencyChangeDetection.GetChanges(dependenciesFile,lockFile,true) let hasChanges groupName x = let hasChanges = hasChanges groupName x diff --git a/tests/Paket.Tests/DependenciesFile/DependencyChangesSpecs.fs b/tests/Paket.Tests/DependenciesFile/DependencyChangesSpecs.fs index f3dff87171..16c958f552 100644 --- a/tests/Paket.Tests/DependenciesFile/DependencyChangesSpecs.fs +++ b/tests/Paket.Tests/DependenciesFile/DependencyChangesSpecs.fs @@ -29,7 +29,7 @@ NUGET let cfg = DependenciesFile.FromCode(after) let lockFile = LockFile.Parse("",toLines lockFileData) - let changedDependencies = DependencyChangeDetection.findNuGetChangesInDependenciesFile(cfg,lockFile) + let changedDependencies = DependencyChangeDetection.findNuGetChangesInDependenciesFile(cfg,lockFile,true) changedDependencies.IsEmpty |> shouldEqual true [] @@ -61,7 +61,7 @@ nuget Castle.Windsor-log4net""" let cfg = DependenciesFile.FromCode(after) let lockFile = LockFile.Parse("",toLines lockFileData) - let changedDependencies = DependencyChangeDetection.findNuGetChangesInDependenciesFile(cfg,lockFile) + let changedDependencies = DependencyChangeDetection.findNuGetChangesInDependenciesFile(cfg,lockFile,true) let newDependencies = DependencyChangeDetection.GetPreferredNuGetVersions(cfg,lockFile) newDependencies |> Map.filter (fun k v -> not <| changedDependencies.Contains(k)) @@ -98,7 +98,7 @@ nuget NUnit""" let cfg = DependenciesFile.FromCode(after) let lockFile = LockFile.Parse("",toLines lockFileData) - let changedDependencies = DependencyChangeDetection.findNuGetChangesInDependenciesFile(cfg,lockFile) + let changedDependencies = DependencyChangeDetection.findNuGetChangesInDependenciesFile(cfg,lockFile,true) let newDependencies = DependencyChangeDetection.GetPreferredNuGetVersions (cfg,lockFile) let expected = @@ -146,7 +146,7 @@ nuget Castle.Windsor-log4net >= 3.3.0""" let cfg = DependenciesFile.FromCode(after) let lockFile = LockFile.Parse("",toLines lockFileData) - let changedDependencies = DependencyChangeDetection.findNuGetChangesInDependenciesFile(cfg,lockFile) + let changedDependencies = DependencyChangeDetection.findNuGetChangesInDependenciesFile(cfg,lockFile,true) let newDependencies = DependencyChangeDetection.GetPreferredNuGetVersions (cfg,lockFile) let expected = @@ -193,7 +193,7 @@ nuget Castle.Windsor-log4net >= 3.4.0""" let cfg = DependenciesFile.FromCode(after) let lockFile = LockFile.Parse("",toLines lockFileData) - let changedDependencies = DependencyChangeDetection.findNuGetChangesInDependenciesFile(cfg,lockFile) + let changedDependencies = DependencyChangeDetection.findNuGetChangesInDependenciesFile(cfg,lockFile,true) let newDependencies = DependencyChangeDetection.GetPreferredNuGetVersions (cfg,lockFile) newDependencies @@ -230,7 +230,7 @@ nuget Castle.Windsor-log4net content:none""" let cfg = DependenciesFile.FromCode(after) let lockFile = LockFile.Parse("",toLines lockFileData) - let changedDependencies = DependencyChangeDetection.findNuGetChangesInDependenciesFile(cfg,lockFile) + let changedDependencies = DependencyChangeDetection.findNuGetChangesInDependenciesFile(cfg,lockFile,true) changedDependencies.IsEmpty |> shouldEqual false [] @@ -295,7 +295,7 @@ nuget Caliburn.Micro !~> 2.0.2""" let cfg = DependenciesFile.FromCode(after) let lockFile = LockFile.Parse("",toLines lockFileData) - let changedDependencies = DependencyChangeDetection.findNuGetChangesInDependenciesFile(cfg,lockFile) + let changedDependencies = DependencyChangeDetection.findNuGetChangesInDependenciesFile(cfg,lockFile,true) changedDependencies.Count |> shouldEqual 1 (changedDependencies |> Seq.head) |> shouldEqual (Constants.MainDependencyGroup, PackageName "Caliburn.Micro")