From bcc5cb59944379542ca7ba027070aa35d0cd151c Mon Sep 17 00:00:00 2001 From: Carolyn Van Slyck Date: Fri, 28 Apr 2017 11:18:23 -0500 Subject: [PATCH 1/2] Do not write the manifest during ensure anymore Now that the manifest is user managed, do not rewrite the entire file anymore so as to preserve comments, etc. In the future commands may append/tweak the manifest, but not completely rewrite it. --- cmd/dep/ensure.go | 9 +-- .../ensure/empty/case2/final/Gopkg.toml | 55 +------------------ .../ensure/empty/case3/final/Gopkg.toml | 52 ------------------ .../ensure/override/case1/final/Gopkg.toml | 4 -- .../status/case1/final/Gopkg.toml | 55 +------------------ 5 files changed, 4 insertions(+), 171 deletions(-) diff --git a/cmd/dep/ensure.go b/cmd/dep/ensure.go index 22d48898e1..c2cd9e17a8 100644 --- a/cmd/dep/ensure.go +++ b/cmd/dep/ensure.go @@ -27,7 +27,7 @@ const ensureLongHelp = ` Ensure is used to fetch project dependencies into the vendor folder, as well as to set version constraints for specific dependencies. It takes user input, solves the updated dependency graph of the project, writes any changes to the -manifest and lock file, and places dependencies in the vendor folder. +lock file, and places dependencies in the vendor folder. Package spec: @@ -161,13 +161,8 @@ func (cmd *ensureCommand) Run(ctx *dep.Ctx, args []string) error { } var sw dep.SafeWriter - var manifest *dep.Manifest - if !cmd.update { - manifest = p.Manifest - } - newLock := dep.LockFromInterface(solution) - sw.Prepare(manifest, p.Lock, newLock, writeV) + sw.Prepare(nil, p.Lock, newLock, writeV) if cmd.dryRun { return sw.PrintPreparedActions() } diff --git a/cmd/dep/testdata/harness_tests/ensure/empty/case2/final/Gopkg.toml b/cmd/dep/testdata/harness_tests/ensure/empty/case2/final/Gopkg.toml index f00cb6004e..d327c51ade 100644 --- a/cmd/dep/testdata/harness_tests/ensure/empty/case2/final/Gopkg.toml +++ b/cmd/dep/testdata/harness_tests/ensure/empty/case2/final/Gopkg.toml @@ -1,56 +1,3 @@ - -## Gopkg.toml example (these lines may be deleted) - -## "required" lists a set of packages (not projects) that must be included in -## Gopkg.lock. This list is merged with the set of packages imported by the current -## project. Use it when your project needs a package it doesn't explicitly import - -## including "main" packages. -# required = ["github.com/user/thing/cmd/thing"] - -## "ignored" lists a set of packages (not projects) that are ignored when -## dep statically analyzes source code. Ignored packages can be in this project, -## or in a dependency. -# ignored = ["github.com/user/project/badpkg"] - -## Dependencies define constraints on dependent projects. They are respected by -## dep whether coming from the Gopkg.toml of the current project or a dependency. -# [[dependencies]] -## Required: the root import path of the project being constrained. -# name = "github.com/user/project" -# -## Recommended: the version constraint to enforce for the project. -## Only one of "branch", "version" or "revision" can be specified. -# version = "1.0.0" -# branch = "master" -# revision = "abc123" -# -## Optional: an alternate location (URL or import path) for the project's source. -# source = "https://github.com/myfork/package.git" - -## Overrides have the same structure as [[dependencies]], but supercede all -## [[dependencies]] declarations from all projects. Only the current project's -## [[overrides]] are applied. -## -## Overrides are a sledgehammer. Use them only as a last resort. -# [[overrides]] -## Required: the root import path of the project being constrained. -# name = "github.com/user/project" -# -## Optional: specifying a version constraint override will cause all other -## constraints on this project to be ignored; only the overriden constraint -## need be satisfied. -## Again, only one of "branch", "version" or "revision" can be specified. -# version = "1.0.0" -# branch = "master" -# revision = "abc123" -# -## Optional: specifying an alternate source location as an override will -## enforce that the alternate location is used for that project, regardless of -## what source location any dependent projects specify. -# source = "https://github.com/myfork/package.git" - - - [[dependencies]] name = "github.com/sdboyer/deptest" - version = "^0.8.0" + version = "~0.8.0" \ No newline at end of file diff --git a/cmd/dep/testdata/harness_tests/ensure/empty/case3/final/Gopkg.toml b/cmd/dep/testdata/harness_tests/ensure/empty/case3/final/Gopkg.toml index 3988c0b041..dd0150055a 100644 --- a/cmd/dep/testdata/harness_tests/ensure/empty/case3/final/Gopkg.toml +++ b/cmd/dep/testdata/harness_tests/ensure/empty/case3/final/Gopkg.toml @@ -1,55 +1,3 @@ - -## Gopkg.toml example (these lines may be deleted) - -## "required" lists a set of packages (not projects) that must be included in -## Gopkg.lock. This list is merged with the set of packages imported by the current -## project. Use it when your project needs a package it doesn't explicitly import - -## including "main" packages. -# required = ["github.com/user/thing/cmd/thing"] - -## "ignored" lists a set of packages (not projects) that are ignored when -## dep statically analyzes source code. Ignored packages can be in this project, -## or in a dependency. -# ignored = ["github.com/user/project/badpkg"] - -## Dependencies define constraints on dependent projects. They are respected by -## dep whether coming from the Gopkg.toml of the current project or a dependency. -# [[dependencies]] -## Required: the root import path of the project being constrained. -# name = "github.com/user/project" -# -## Recommended: the version constraint to enforce for the project. -## Only one of "branch", "version" or "revision" can be specified. -# version = "1.0.0" -# branch = "master" -# revision = "abc123" -# -## Optional: an alternate location (URL or import path) for the project's source. -# source = "https://github.com/myfork/package.git" - -## Overrides have the same structure as [[dependencies]], but supercede all -## [[dependencies]] declarations from all projects. Only the current project's -## [[overrides]] are applied. -## -## Overrides are a sledgehammer. Use them only as a last resort. -# [[overrides]] -## Required: the root import path of the project being constrained. -# name = "github.com/user/project" -# -## Optional: specifying a version constraint override will cause all other -## constraints on this project to be ignored; only the overriden constraint -## need be satisfied. -## Again, only one of "branch", "version" or "revision" can be specified. -# version = "1.0.0" -# branch = "master" -# revision = "abc123" -# -## Optional: specifying an alternate source location as an override will -## enforce that the alternate location is used for that project, regardless of -## what source location any dependent projects specify. -# source = "https://github.com/myfork/package.git" - - ignored = ["github.com/sdboyer/deptestdos"] [[dependencies]] diff --git a/cmd/dep/testdata/harness_tests/ensure/override/case1/final/Gopkg.toml b/cmd/dep/testdata/harness_tests/ensure/override/case1/final/Gopkg.toml index d4b673fcb6..6b7a32babb 100644 --- a/cmd/dep/testdata/harness_tests/ensure/override/case1/final/Gopkg.toml +++ b/cmd/dep/testdata/harness_tests/ensure/override/case1/final/Gopkg.toml @@ -50,7 +50,3 @@ # source = "https://github.com/myfork/package.git" - -[[overrides]] - name = "github.com/sdboyer/deptest" - version = "1.0.0" diff --git a/cmd/dep/testdata/harness_tests/status/case1/final/Gopkg.toml b/cmd/dep/testdata/harness_tests/status/case1/final/Gopkg.toml index 4df6b969b4..122d0340fd 100644 --- a/cmd/dep/testdata/harness_tests/status/case1/final/Gopkg.toml +++ b/cmd/dep/testdata/harness_tests/status/case1/final/Gopkg.toml @@ -1,56 +1,3 @@ - -## Gopkg.toml example (these lines may be deleted) - -## "required" lists a set of packages (not projects) that must be included in -## Gopkg.lock. This list is merged with the set of packages imported by the current -## project. Use it when your project needs a package it doesn't explicitly import - -## including "main" packages. -# required = ["github.com/user/thing/cmd/thing"] - -## "ignored" lists a set of packages (not projects) that are ignored when -## dep statically analyzes source code. Ignored packages can be in this project, -## or in a dependency. -# ignored = ["github.com/user/project/badpkg"] - -## Dependencies define constraints on dependent projects. They are respected by -## dep whether coming from the Gopkg.toml of the current project or a dependency. -# [[dependencies]] -## Required: the root import path of the project being constrained. -# name = "github.com/user/project" -# -## Recommended: the version constraint to enforce for the project. -## Only one of "branch", "version" or "revision" can be specified. -# version = "1.0.0" -# branch = "master" -# revision = "abc123" -# -## Optional: an alternate location (URL or import path) for the project's source. -# source = "https://github.com/myfork/package.git" - -## Overrides have the same structure as [[dependencies]], but supercede all -## [[dependencies]] declarations from all projects. Only the current project's -## [[overrides]] are applied. -## -## Overrides are a sledgehammer. Use them only as a last resort. -# [[overrides]] -## Required: the root import path of the project being constrained. -# name = "github.com/user/project" -# -## Optional: specifying a version constraint override will cause all other -## constraints on this project to be ignored; only the overriden constraint -## need be satisfied. -## Again, only one of "branch", "version" or "revision" can be specified. -# version = "1.0.0" -# branch = "master" -# revision = "abc123" -# -## Optional: specifying an alternate source location as an override will -## enforce that the alternate location is used for that project, regardless of -## what source location any dependent projects specify. -# source = "https://github.com/myfork/package.git" - - - [[dependencies]] name = "github.com/sdboyer/deptest" - version = ">=0.8.0, <1.0.0" + version = "^0.8.0" From 28956691fb92ebc2dd34dbaa0d680332172da92d Mon Sep 17 00:00:00 2001 From: Carolyn Van Slyck Date: Fri, 28 Apr 2017 11:19:27 -0500 Subject: [PATCH 2/2] Do not write the manifest during remove anymore This is a stop-gap until the new command set is implemented. Remove now only modifies the lock. --- cmd/dep/remove.go | 4 +- .../remove/force/case1/final/Gopkg.toml | 59 +++--------------- .../remove/specific/case1/final/Gopkg.toml | 61 ++----------------- .../remove/specific/case2/final/Gopkg.toml | 57 ++--------------- .../remove/unused/case1/final/Gopkg.toml | 57 ++--------------- 5 files changed, 23 insertions(+), 215 deletions(-) diff --git a/cmd/dep/remove.go b/cmd/dep/remove.go index b3bd5db8f9..7a37875393 100644 --- a/cmd/dep/remove.go +++ b/cmd/dep/remove.go @@ -19,7 +19,7 @@ import ( const removeShortHelp = `Remove a dependency from the project` const removeLongHelp = ` -Remove a dependency from the project's manifest file, lock file, and vendor +Remove a dependency from the project's lock file, and vendor folder. If the project includes that dependency in its import graph, remove will fail unless -force is specified. ` @@ -182,7 +182,7 @@ func (cmd *removeCommand) Run(ctx *dep.Ctx, args []string) error { var sw dep.SafeWriter newLock := dep.LockFromInterface(soln) - sw.Prepare(p.Manifest, p.Lock, newLock, dep.VendorOnChanged) + sw.Prepare(nil, p.Lock, newLock, dep.VendorOnChanged) if err := sw.Write(p.AbsRoot, sm); err != nil { return errors.Wrap(err, "grouped write of manifest, lock and vendor") } diff --git a/cmd/dep/testdata/harness_tests/remove/force/case1/final/Gopkg.toml b/cmd/dep/testdata/harness_tests/remove/force/case1/final/Gopkg.toml index 4df6b969b4..413feb4eb0 100644 --- a/cmd/dep/testdata/harness_tests/remove/force/case1/final/Gopkg.toml +++ b/cmd/dep/testdata/harness_tests/remove/force/case1/final/Gopkg.toml @@ -1,56 +1,11 @@ - -## Gopkg.toml example (these lines may be deleted) - -## "required" lists a set of packages (not projects) that must be included in -## Gopkg.lock. This list is merged with the set of packages imported by the current -## project. Use it when your project needs a package it doesn't explicitly import - -## including "main" packages. -# required = ["github.com/user/thing/cmd/thing"] - -## "ignored" lists a set of packages (not projects) that are ignored when -## dep statically analyzes source code. Ignored packages can be in this project, -## or in a dependency. -# ignored = ["github.com/user/project/badpkg"] - -## Dependencies define constraints on dependent projects. They are respected by -## dep whether coming from the Gopkg.toml of the current project or a dependency. -# [[dependencies]] -## Required: the root import path of the project being constrained. -# name = "github.com/user/project" -# -## Recommended: the version constraint to enforce for the project. -## Only one of "branch", "version" or "revision" can be specified. -# version = "1.0.0" -# branch = "master" -# revision = "abc123" -# -## Optional: an alternate location (URL or import path) for the project's source. -# source = "https://github.com/myfork/package.git" - -## Overrides have the same structure as [[dependencies]], but supercede all -## [[dependencies]] declarations from all projects. Only the current project's -## [[overrides]] are applied. -## -## Overrides are a sledgehammer. Use them only as a last resort. -# [[overrides]] -## Required: the root import path of the project being constrained. -# name = "github.com/user/project" -# -## Optional: specifying a version constraint override will cause all other -## constraints on this project to be ignored; only the overriden constraint -## need be satisfied. -## Again, only one of "branch", "version" or "revision" can be specified. -# version = "1.0.0" -# branch = "master" -# revision = "abc123" -# -## Optional: specifying an alternate source location as an override will -## enforce that the alternate location is used for that project, regardless of -## what source location any dependent projects specify. -# source = "https://github.com/myfork/package.git" - - +[[dependencies]] + name = "github.com/not/used" + version = "2.0.0" [[dependencies]] name = "github.com/sdboyer/deptest" version = ">=0.8.0, <1.0.0" + +[[dependencies]] + name = "github.com/sdboyer/deptestdos" + revision = "a0196baa11ea047dd65037287451d36b861b00ea" diff --git a/cmd/dep/testdata/harness_tests/remove/specific/case1/final/Gopkg.toml b/cmd/dep/testdata/harness_tests/remove/specific/case1/final/Gopkg.toml index 7e37517cde..26653704de 100644 --- a/cmd/dep/testdata/harness_tests/remove/specific/case1/final/Gopkg.toml +++ b/cmd/dep/testdata/harness_tests/remove/specific/case1/final/Gopkg.toml @@ -1,60 +1,11 @@ - -## Gopkg.toml example (these lines may be deleted) - -## "required" lists a set of packages (not projects) that must be included in -## Gopkg.lock. This list is merged with the set of packages imported by the current -## project. Use it when your project needs a package it doesn't explicitly import - -## including "main" packages. -# required = ["github.com/user/thing/cmd/thing"] - -## "ignored" lists a set of packages (not projects) that are ignored when -## dep statically analyzes source code. Ignored packages can be in this project, -## or in a dependency. -# ignored = ["github.com/user/project/badpkg"] - -## Dependencies define constraints on dependent projects. They are respected by -## dep whether coming from the Gopkg.toml of the current project or a dependency. -# [[dependencies]] -## Required: the root import path of the project being constrained. -# name = "github.com/user/project" -# -## Recommended: the version constraint to enforce for the project. -## Only one of "branch", "version" or "revision" can be specified. -# version = "1.0.0" -# branch = "master" -# revision = "abc123" -# -## Optional: an alternate location (URL or import path) for the project's source. -# source = "https://github.com/myfork/package.git" - -## Overrides have the same structure as [[dependencies]], but supercede all -## [[dependencies]] declarations from all projects. Only the current project's -## [[overrides]] are applied. -## -## Overrides are a sledgehammer. Use them only as a last resort. -# [[overrides]] -## Required: the root import path of the project being constrained. -# name = "github.com/user/project" -# -## Optional: specifying a version constraint override will cause all other -## constraints on this project to be ignored; only the overriden constraint -## need be satisfied. -## Again, only one of "branch", "version" or "revision" can be specified. -# version = "1.0.0" -# branch = "master" -# revision = "abc123" -# -## Optional: specifying an alternate source location as an override will -## enforce that the alternate location is used for that project, regardless of -## what source location any dependent projects specify. -# source = "https://github.com/myfork/package.git" - - +[[dependencies]] + name = "github.com/not/used" + version = "2.0.0" [[dependencies]] - name = "github.com/sdboyer/deptest" +name = "github.com/sdboyer/deptest" version = ">=0.8.0, <1.0.0" [[dependencies]] - name = "github.com/sdboyer/deptestdos" - revision = "a0196baa11ea047dd65037287451d36b861b00ea" +name = "github.com/sdboyer/deptestdos" + revision = "a0196baa11ea047dd65037287451d36b861b00ea" \ No newline at end of file diff --git a/cmd/dep/testdata/harness_tests/remove/specific/case2/final/Gopkg.toml b/cmd/dep/testdata/harness_tests/remove/specific/case2/final/Gopkg.toml index 7e37517cde..0bb0ab1d1b 100644 --- a/cmd/dep/testdata/harness_tests/remove/specific/case2/final/Gopkg.toml +++ b/cmd/dep/testdata/harness_tests/remove/specific/case2/final/Gopkg.toml @@ -1,55 +1,6 @@ - -## Gopkg.toml example (these lines may be deleted) - -## "required" lists a set of packages (not projects) that must be included in -## Gopkg.lock. This list is merged with the set of packages imported by the current -## project. Use it when your project needs a package it doesn't explicitly import - -## including "main" packages. -# required = ["github.com/user/thing/cmd/thing"] - -## "ignored" lists a set of packages (not projects) that are ignored when -## dep statically analyzes source code. Ignored packages can be in this project, -## or in a dependency. -# ignored = ["github.com/user/project/badpkg"] - -## Dependencies define constraints on dependent projects. They are respected by -## dep whether coming from the Gopkg.toml of the current project or a dependency. -# [[dependencies]] -## Required: the root import path of the project being constrained. -# name = "github.com/user/project" -# -## Recommended: the version constraint to enforce for the project. -## Only one of "branch", "version" or "revision" can be specified. -# version = "1.0.0" -# branch = "master" -# revision = "abc123" -# -## Optional: an alternate location (URL or import path) for the project's source. -# source = "https://github.com/myfork/package.git" - -## Overrides have the same structure as [[dependencies]], but supercede all -## [[dependencies]] declarations from all projects. Only the current project's -## [[overrides]] are applied. -## -## Overrides are a sledgehammer. Use them only as a last resort. -# [[overrides]] -## Required: the root import path of the project being constrained. -# name = "github.com/user/project" -# -## Optional: specifying a version constraint override will cause all other -## constraints on this project to be ignored; only the overriden constraint -## need be satisfied. -## Again, only one of "branch", "version" or "revision" can be specified. -# version = "1.0.0" -# branch = "master" -# revision = "abc123" -# -## Optional: specifying an alternate source location as an override will -## enforce that the alternate location is used for that project, regardless of -## what source location any dependent projects specify. -# source = "https://github.com/myfork/package.git" - - +[[dependencies]] + name = "github.com/not/used" + version = "2.0.0" [[dependencies]] name = "github.com/sdboyer/deptest" @@ -57,4 +8,4 @@ [[dependencies]] name = "github.com/sdboyer/deptestdos" - revision = "a0196baa11ea047dd65037287451d36b861b00ea" + revision = "a0196baa11ea047dd65037287451d36b861b00ea" \ No newline at end of file diff --git a/cmd/dep/testdata/harness_tests/remove/unused/case1/final/Gopkg.toml b/cmd/dep/testdata/harness_tests/remove/unused/case1/final/Gopkg.toml index 7e37517cde..0bb0ab1d1b 100644 --- a/cmd/dep/testdata/harness_tests/remove/unused/case1/final/Gopkg.toml +++ b/cmd/dep/testdata/harness_tests/remove/unused/case1/final/Gopkg.toml @@ -1,55 +1,6 @@ - -## Gopkg.toml example (these lines may be deleted) - -## "required" lists a set of packages (not projects) that must be included in -## Gopkg.lock. This list is merged with the set of packages imported by the current -## project. Use it when your project needs a package it doesn't explicitly import - -## including "main" packages. -# required = ["github.com/user/thing/cmd/thing"] - -## "ignored" lists a set of packages (not projects) that are ignored when -## dep statically analyzes source code. Ignored packages can be in this project, -## or in a dependency. -# ignored = ["github.com/user/project/badpkg"] - -## Dependencies define constraints on dependent projects. They are respected by -## dep whether coming from the Gopkg.toml of the current project or a dependency. -# [[dependencies]] -## Required: the root import path of the project being constrained. -# name = "github.com/user/project" -# -## Recommended: the version constraint to enforce for the project. -## Only one of "branch", "version" or "revision" can be specified. -# version = "1.0.0" -# branch = "master" -# revision = "abc123" -# -## Optional: an alternate location (URL or import path) for the project's source. -# source = "https://github.com/myfork/package.git" - -## Overrides have the same structure as [[dependencies]], but supercede all -## [[dependencies]] declarations from all projects. Only the current project's -## [[overrides]] are applied. -## -## Overrides are a sledgehammer. Use them only as a last resort. -# [[overrides]] -## Required: the root import path of the project being constrained. -# name = "github.com/user/project" -# -## Optional: specifying a version constraint override will cause all other -## constraints on this project to be ignored; only the overriden constraint -## need be satisfied. -## Again, only one of "branch", "version" or "revision" can be specified. -# version = "1.0.0" -# branch = "master" -# revision = "abc123" -# -## Optional: specifying an alternate source location as an override will -## enforce that the alternate location is used for that project, regardless of -## what source location any dependent projects specify. -# source = "https://github.com/myfork/package.git" - - +[[dependencies]] + name = "github.com/not/used" + version = "2.0.0" [[dependencies]] name = "github.com/sdboyer/deptest" @@ -57,4 +8,4 @@ [[dependencies]] name = "github.com/sdboyer/deptestdos" - revision = "a0196baa11ea047dd65037287451d36b861b00ea" + revision = "a0196baa11ea047dd65037287451d36b861b00ea" \ No newline at end of file