From d39a7b1e366bc44e8cf4cf191fc57d125880ff24 Mon Sep 17 00:00:00 2001 From: Steffen Forkmann Date: Fri, 24 Jun 2016 11:03:18 +0200 Subject: [PATCH] Add --ignore-checks parameter for restore - references #1750 --- RELEASE_NOTES.md | 2 +- src/Paket.Core/PublicAPI.fs | 20 +++++++++++++------- src/Paket.Core/RestoreProcess.fs | 9 +++++---- src/Paket/Commands.fs | 2 ++ src/Paket/Program.fs | 5 +++-- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/RELEASE_NOTES.md b/RELEASE_NOTES.md index 7eb04b85da..817e70ebb4 100644 --- a/RELEASE_NOTES.md +++ b/RELEASE_NOTES.md @@ -1,4 +1,4 @@ -#### 3.2.0-alpha004 - 23.06.2016 +#### 3.2.0-alpha005 - 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/PublicAPI.fs b/src/Paket.Core/PublicAPI.fs index 57fba9301d..51e06ab65b 100644 --- a/src/Paket.Core/PublicAPI.fs +++ b/src/Paket.Core/PublicAPI.fs @@ -241,26 +241,32 @@ type Dependencies(dependenciesFileName: string) = NoInstall = installAfter |> not })) /// Restores all dependencies. - member this.Restore(): unit = this.Restore(false,None,[],false) + member this.Restore(ignoreChecks): unit = this.Restore(false,None,[],false,ignoreChecks) + + /// Restores all dependencies. + member this.Restore(): unit = this.Restore(false,None,[],false,false) + + /// Restores the given paket.references files. + member this.Restore(group: string option, files: string list, ignoreChecks): unit = this.Restore(false, group, files, false, ignoreChecks) /// Restores the given paket.references files. - member this.Restore(group: string option, files: string list): unit = this.Restore(false, group, files, false) + member this.Restore(group: string option, files: string list): unit = this.Restore(false, group, files, false, false) /// Restores the given paket.references files. - member this.Restore(force: bool, group: string option, files: string list, touchAffectedRefs: bool): unit = + member this.Restore(force: bool, group: string option, files: string list, touchAffectedRefs: bool, ignoreChecks) : unit = Utils.RunInLockedAccessMode( this.RootPath, fun () -> if touchAffectedRefs then let packagesToTouch = RestoreProcess.FindPackagesNotExtractedYet(dependenciesFileName) this.Process (FindReferences.TouchReferencesOfPackages packagesToTouch) - RestoreProcess.Restore(dependenciesFileName,force,Option.map GroupName group,files)) + RestoreProcess.Restore(dependenciesFileName,force,Option.map GroupName group,files,ignoreChecks)) /// Restores packages for all available paket.references files /// (or all packages if onlyReferenced is false) - member this.Restore(force: bool, group: string option, onlyReferenced: bool, touchAffectedRefs: bool): unit = + member this.Restore(force: bool, group: string option, onlyReferenced: bool, touchAffectedRefs: bool, ignoreChecks): unit = if not onlyReferenced then - this.Restore(force,group,[],touchAffectedRefs) + this.Restore(force,group,[],touchAffectedRefs,ignoreChecks) else let referencesFiles = this.RootPath @@ -269,7 +275,7 @@ type Dependencies(dependenciesFileName: string) = if Array.isEmpty referencesFiles then traceWarnfn "No paket.references files found for which packages could be installed." else - this.Restore(force, group, Array.toList referencesFiles, touchAffectedRefs) + this.Restore(force, group, Array.toList referencesFiles, touchAffectedRefs, ignoreChecks) /// Lists outdated packages. member this.ShowOutdated(strict: bool,includePrereleases: bool): unit = diff --git a/src/Paket.Core/RestoreProcess.fs b/src/Paket.Core/RestoreProcess.fs index c68ef3710e..503dd37e27 100644 --- a/src/Paket.Core/RestoreProcess.fs +++ b/src/Paket.Core/RestoreProcess.fs @@ -110,7 +110,7 @@ let internal computePackageHull groupName (lockFile : LockFile) (referencesFileN |> Seq.map (fun p -> (snd p.Key))) |> Seq.concat -let Restore(dependenciesFileName,force,group,referencesFileNames) = +let Restore(dependenciesFileName,force,group,referencesFileNames,ignoreChecks) = let lockFileName = DependenciesFile.FindLockfile dependenciesFileName let localFileName = DependenciesFile.FindLocalfile dependenciesFileName let root = lockFileName.Directory.FullName @@ -129,10 +129,11 @@ let Restore(dependenciesFileName,force,group,referencesFileNames) = LockFile.LoadFrom(lockFileName.FullName) |> LocalFile.overrideLockFile localFile - let hasAnyChanges,_,_,_ = DependencyChangeDetection.GetChanges(dependenciesFile,lockFile,false) + if not ignoreChecks then + 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 + 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 diff --git a/src/Paket/Commands.fs b/src/Paket/Commands.fs index 96ac82104e..bd318fe36b 100644 --- a/src/Paket/Commands.fs +++ b/src/Paket/Commands.fs @@ -206,6 +206,7 @@ type RestoreArgs = | [] Force | [] Install_Only_Referenced | [] Touch_Affected_Refs + | [] Ignore_Checks | [] Group of string | [] References_Files of string with @@ -216,6 +217,7 @@ with | Group(_) -> "Allows to restore a single group." | Install_Only_Referenced -> "Allows to restore packages that are referenced in paket.references files, instead of all packages in paket.dependencies." | Touch_Affected_Refs -> "Touches project files referencing packages which are being restored, to help incremental build tools detecting the change." + | Ignore_Checks -> "Skips the test if paket.dependencies and paket.lock are in sync." | References_Files(_) -> "Allows to restore all packages from the given paket.references files. This implies --only-referenced." type SimplifyArgs = diff --git a/src/Paket/Program.fs b/src/Paket/Program.fs index 441da5a234..43a44bd96e 100644 --- a/src/Paket/Program.fs +++ b/src/Paket/Program.fs @@ -181,8 +181,9 @@ let restore (results : ParseResults<_>) = let group = results.TryGetResult <@ RestoreArgs.Group @> let installOnlyReferenced = results.Contains <@ RestoreArgs.Install_Only_Referenced @> let touchAffectedRefs = results.Contains <@ RestoreArgs.Touch_Affected_Refs @> - if List.isEmpty files then Dependencies.Locate().Restore(force, group, installOnlyReferenced, touchAffectedRefs) - else Dependencies.Locate().Restore(force, group, files, touchAffectedRefs) + let ignoreChecks = results.Contains <@ RestoreArgs.Ignore_Checks @> + if List.isEmpty files then Dependencies.Locate().Restore(force, group, installOnlyReferenced, touchAffectedRefs, ignoreChecks) + else Dependencies.Locate().Restore(force, group, files, touchAffectedRefs, ignoreChecks) let simplify (results : ParseResults<_>) = let interactive = results.Contains <@ SimplifyArgs.Interactive @>