Skip to content

Commit de7d4ff

Browse files
authored
Merge pull request golang#480 from carolynvs/manifest-is-user-edit-only
Only write to the manifest during dep init
2 parents 6cb4c60 + 6c022f5 commit de7d4ff

File tree

10 files changed

+27
-386
lines changed

10 files changed

+27
-386
lines changed

cmd/dep/ensure.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ const ensureLongHelp = `
2727
Ensure is used to fetch project dependencies into the vendor folder, as well as
2828
to set version constraints for specific dependencies. It takes user input,
2929
solves the updated dependency graph of the project, writes any changes to the
30-
manifest and lock file, and places dependencies in the vendor folder.
30+
lock file, and places dependencies in the vendor folder.
3131
3232
Package spec:
3333
@@ -161,13 +161,8 @@ func (cmd *ensureCommand) Run(ctx *dep.Ctx, args []string) error {
161161
}
162162

163163
var sw dep.SafeWriter
164-
var manifest *dep.Manifest
165-
if !cmd.update {
166-
manifest = p.Manifest
167-
}
168-
169164
newLock := dep.LockFromInterface(solution)
170-
sw.Prepare(manifest, p.Lock, newLock, writeV)
165+
sw.Prepare(nil, p.Lock, newLock, writeV)
171166
if cmd.dryRun {
172167
return sw.PrintPreparedActions()
173168
}

cmd/dep/remove.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ import (
1919

2020
const removeShortHelp = `Remove a dependency from the project`
2121
const removeLongHelp = `
22-
Remove a dependency from the project's manifest file, lock file, and vendor
22+
Remove a dependency from the project's lock file, and vendor
2323
folder. If the project includes that dependency in its import graph, remove will
2424
fail unless -force is specified.
2525
`
@@ -182,7 +182,7 @@ func (cmd *removeCommand) Run(ctx *dep.Ctx, args []string) error {
182182

183183
var sw dep.SafeWriter
184184
newLock := dep.LockFromInterface(soln)
185-
sw.Prepare(p.Manifest, p.Lock, newLock, dep.VendorOnChanged)
185+
sw.Prepare(nil, p.Lock, newLock, dep.VendorOnChanged)
186186
if err := sw.Write(p.AbsRoot, sm); err != nil {
187187
return errors.Wrap(err, "grouped write of manifest, lock and vendor")
188188
}
Lines changed: 1 addition & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,3 @@
1-
2-
## Gopkg.toml example (these lines may be deleted)
3-
4-
## "required" lists a set of packages (not projects) that must be included in
5-
## Gopkg.lock. This list is merged with the set of packages imported by the current
6-
## project. Use it when your project needs a package it doesn't explicitly import -
7-
## including "main" packages.
8-
# required = ["github.com/user/thing/cmd/thing"]
9-
10-
## "ignored" lists a set of packages (not projects) that are ignored when
11-
## dep statically analyzes source code. Ignored packages can be in this project,
12-
## or in a dependency.
13-
# ignored = ["github.com/user/project/badpkg"]
14-
15-
## Dependencies define constraints on dependent projects. They are respected by
16-
## dep whether coming from the Gopkg.toml of the current project or a dependency.
17-
# [[dependencies]]
18-
## Required: the root import path of the project being constrained.
19-
# name = "github.com/user/project"
20-
#
21-
## Recommended: the version constraint to enforce for the project.
22-
## Only one of "branch", "version" or "revision" can be specified.
23-
# version = "1.0.0"
24-
# branch = "master"
25-
# revision = "abc123"
26-
#
27-
## Optional: an alternate location (URL or import path) for the project's source.
28-
# source = "https://github.com/myfork/package.git"
29-
30-
## Overrides have the same structure as [[dependencies]], but supercede all
31-
## [[dependencies]] declarations from all projects. Only the current project's
32-
## [[overrides]] are applied.
33-
##
34-
## Overrides are a sledgehammer. Use them only as a last resort.
35-
# [[overrides]]
36-
## Required: the root import path of the project being constrained.
37-
# name = "github.com/user/project"
38-
#
39-
## Optional: specifying a version constraint override will cause all other
40-
## constraints on this project to be ignored; only the overriden constraint
41-
## need be satisfied.
42-
## Again, only one of "branch", "version" or "revision" can be specified.
43-
# version = "1.0.0"
44-
# branch = "master"
45-
# revision = "abc123"
46-
#
47-
## Optional: specifying an alternate source location as an override will
48-
## enforce that the alternate location is used for that project, regardless of
49-
## what source location any dependent projects specify.
50-
# source = "https://github.com/myfork/package.git"
51-
52-
53-
541
[[dependencies]]
552
name = "github.com/sdboyer/deptest"
56-
version = "^0.8.0"
3+
version = "~0.8.0"

cmd/dep/testdata/harness_tests/ensure/empty/case3/final/Gopkg.toml

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,3 @@
1-
2-
## Gopkg.toml example (these lines may be deleted)
3-
4-
## "required" lists a set of packages (not projects) that must be included in
5-
## Gopkg.lock. This list is merged with the set of packages imported by the current
6-
## project. Use it when your project needs a package it doesn't explicitly import -
7-
## including "main" packages.
8-
# required = ["github.com/user/thing/cmd/thing"]
9-
10-
## "ignored" lists a set of packages (not projects) that are ignored when
11-
## dep statically analyzes source code. Ignored packages can be in this project,
12-
## or in a dependency.
13-
# ignored = ["github.com/user/project/badpkg"]
14-
15-
## Dependencies define constraints on dependent projects. They are respected by
16-
## dep whether coming from the Gopkg.toml of the current project or a dependency.
17-
# [[dependencies]]
18-
## Required: the root import path of the project being constrained.
19-
# name = "github.com/user/project"
20-
#
21-
## Recommended: the version constraint to enforce for the project.
22-
## Only one of "branch", "version" or "revision" can be specified.
23-
# version = "1.0.0"
24-
# branch = "master"
25-
# revision = "abc123"
26-
#
27-
## Optional: an alternate location (URL or import path) for the project's source.
28-
# source = "https://github.com/myfork/package.git"
29-
30-
## Overrides have the same structure as [[dependencies]], but supercede all
31-
## [[dependencies]] declarations from all projects. Only the current project's
32-
## [[overrides]] are applied.
33-
##
34-
## Overrides are a sledgehammer. Use them only as a last resort.
35-
# [[overrides]]
36-
## Required: the root import path of the project being constrained.
37-
# name = "github.com/user/project"
38-
#
39-
## Optional: specifying a version constraint override will cause all other
40-
## constraints on this project to be ignored; only the overriden constraint
41-
## need be satisfied.
42-
## Again, only one of "branch", "version" or "revision" can be specified.
43-
# version = "1.0.0"
44-
# branch = "master"
45-
# revision = "abc123"
46-
#
47-
## Optional: specifying an alternate source location as an override will
48-
## enforce that the alternate location is used for that project, regardless of
49-
## what source location any dependent projects specify.
50-
# source = "https://github.com/myfork/package.git"
51-
52-
531
ignored = ["github.com/sdboyer/deptestdos"]
542

553
[[dependencies]]

cmd/dep/testdata/harness_tests/ensure/override/case1/final/Gopkg.toml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,3 @@
5050
# source = "https://github.com/myfork/package.git"
5151

5252

53-
54-
[[overrides]]
55-
name = "github.com/sdboyer/deptest"
56-
version = "1.0.0"
Lines changed: 7 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -1,56 +1,11 @@
1-
2-
## Gopkg.toml example (these lines may be deleted)
3-
4-
## "required" lists a set of packages (not projects) that must be included in
5-
## Gopkg.lock. This list is merged with the set of packages imported by the current
6-
## project. Use it when your project needs a package it doesn't explicitly import -
7-
## including "main" packages.
8-
# required = ["github.com/user/thing/cmd/thing"]
9-
10-
## "ignored" lists a set of packages (not projects) that are ignored when
11-
## dep statically analyzes source code. Ignored packages can be in this project,
12-
## or in a dependency.
13-
# ignored = ["github.com/user/project/badpkg"]
14-
15-
## Dependencies define constraints on dependent projects. They are respected by
16-
## dep whether coming from the Gopkg.toml of the current project or a dependency.
17-
# [[dependencies]]
18-
## Required: the root import path of the project being constrained.
19-
# name = "github.com/user/project"
20-
#
21-
## Recommended: the version constraint to enforce for the project.
22-
## Only one of "branch", "version" or "revision" can be specified.
23-
# version = "1.0.0"
24-
# branch = "master"
25-
# revision = "abc123"
26-
#
27-
## Optional: an alternate location (URL or import path) for the project's source.
28-
# source = "https://github.com/myfork/package.git"
29-
30-
## Overrides have the same structure as [[dependencies]], but supercede all
31-
## [[dependencies]] declarations from all projects. Only the current project's
32-
## [[overrides]] are applied.
33-
##
34-
## Overrides are a sledgehammer. Use them only as a last resort.
35-
# [[overrides]]
36-
## Required: the root import path of the project being constrained.
37-
# name = "github.com/user/project"
38-
#
39-
## Optional: specifying a version constraint override will cause all other
40-
## constraints on this project to be ignored; only the overriden constraint
41-
## need be satisfied.
42-
## Again, only one of "branch", "version" or "revision" can be specified.
43-
# version = "1.0.0"
44-
# branch = "master"
45-
# revision = "abc123"
46-
#
47-
## Optional: specifying an alternate source location as an override will
48-
## enforce that the alternate location is used for that project, regardless of
49-
## what source location any dependent projects specify.
50-
# source = "https://github.com/myfork/package.git"
51-
52-
1+
[[dependencies]]
2+
name = "github.com/not/used"
3+
version = "2.0.0"
534

545
[[dependencies]]
556
name = "github.com/sdboyer/deptest"
567
version = ">=0.8.0, <1.0.0"
8+
9+
[[dependencies]]
10+
name = "github.com/sdboyer/deptestdos"
11+
revision = "a0196baa11ea047dd65037287451d36b861b00ea"
Lines changed: 6 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,11 @@
1-
2-
## Gopkg.toml example (these lines may be deleted)
3-
4-
## "required" lists a set of packages (not projects) that must be included in
5-
## Gopkg.lock. This list is merged with the set of packages imported by the current
6-
## project. Use it when your project needs a package it doesn't explicitly import -
7-
## including "main" packages.
8-
# required = ["github.com/user/thing/cmd/thing"]
9-
10-
## "ignored" lists a set of packages (not projects) that are ignored when
11-
## dep statically analyzes source code. Ignored packages can be in this project,
12-
## or in a dependency.
13-
# ignored = ["github.com/user/project/badpkg"]
14-
15-
## Dependencies define constraints on dependent projects. They are respected by
16-
## dep whether coming from the Gopkg.toml of the current project or a dependency.
17-
# [[dependencies]]
18-
## Required: the root import path of the project being constrained.
19-
# name = "github.com/user/project"
20-
#
21-
## Recommended: the version constraint to enforce for the project.
22-
## Only one of "branch", "version" or "revision" can be specified.
23-
# version = "1.0.0"
24-
# branch = "master"
25-
# revision = "abc123"
26-
#
27-
## Optional: an alternate location (URL or import path) for the project's source.
28-
# source = "https://github.com/myfork/package.git"
29-
30-
## Overrides have the same structure as [[dependencies]], but supercede all
31-
## [[dependencies]] declarations from all projects. Only the current project's
32-
## [[overrides]] are applied.
33-
##
34-
## Overrides are a sledgehammer. Use them only as a last resort.
35-
# [[overrides]]
36-
## Required: the root import path of the project being constrained.
37-
# name = "github.com/user/project"
38-
#
39-
## Optional: specifying a version constraint override will cause all other
40-
## constraints on this project to be ignored; only the overriden constraint
41-
## need be satisfied.
42-
## Again, only one of "branch", "version" or "revision" can be specified.
43-
# version = "1.0.0"
44-
# branch = "master"
45-
# revision = "abc123"
46-
#
47-
## Optional: specifying an alternate source location as an override will
48-
## enforce that the alternate location is used for that project, regardless of
49-
## what source location any dependent projects specify.
50-
# source = "https://github.com/myfork/package.git"
51-
52-
1+
[[dependencies]]
2+
name = "github.com/not/used"
3+
version = "2.0.0"
534

545
[[dependencies]]
55-
name = "github.com/sdboyer/deptest"
6+
name = "github.com/sdboyer/deptest"
567
version = ">=0.8.0, <1.0.0"
578

589
[[dependencies]]
59-
name = "github.com/sdboyer/deptestdos"
60-
revision = "a0196baa11ea047dd65037287451d36b861b00ea"
10+
name = "github.com/sdboyer/deptestdos"
11+
revision = "a0196baa11ea047dd65037287451d36b861b00ea"
Lines changed: 4 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,60 +1,11 @@
1-
2-
## Gopkg.toml example (these lines may be deleted)
3-
4-
## "required" lists a set of packages (not projects) that must be included in
5-
## Gopkg.lock. This list is merged with the set of packages imported by the current
6-
## project. Use it when your project needs a package it doesn't explicitly import -
7-
## including "main" packages.
8-
# required = ["github.com/user/thing/cmd/thing"]
9-
10-
## "ignored" lists a set of packages (not projects) that are ignored when
11-
## dep statically analyzes source code. Ignored packages can be in this project,
12-
## or in a dependency.
13-
# ignored = ["github.com/user/project/badpkg"]
14-
15-
## Dependencies define constraints on dependent projects. They are respected by
16-
## dep whether coming from the Gopkg.toml of the current project or a dependency.
17-
# [[dependencies]]
18-
## Required: the root import path of the project being constrained.
19-
# name = "github.com/user/project"
20-
#
21-
## Recommended: the version constraint to enforce for the project.
22-
## Only one of "branch", "version" or "revision" can be specified.
23-
# version = "1.0.0"
24-
# branch = "master"
25-
# revision = "abc123"
26-
#
27-
## Optional: an alternate location (URL or import path) for the project's source.
28-
# source = "https://github.com/myfork/package.git"
29-
30-
## Overrides have the same structure as [[dependencies]], but supercede all
31-
## [[dependencies]] declarations from all projects. Only the current project's
32-
## [[overrides]] are applied.
33-
##
34-
## Overrides are a sledgehammer. Use them only as a last resort.
35-
# [[overrides]]
36-
## Required: the root import path of the project being constrained.
37-
# name = "github.com/user/project"
38-
#
39-
## Optional: specifying a version constraint override will cause all other
40-
## constraints on this project to be ignored; only the overriden constraint
41-
## need be satisfied.
42-
## Again, only one of "branch", "version" or "revision" can be specified.
43-
# version = "1.0.0"
44-
# branch = "master"
45-
# revision = "abc123"
46-
#
47-
## Optional: specifying an alternate source location as an override will
48-
## enforce that the alternate location is used for that project, regardless of
49-
## what source location any dependent projects specify.
50-
# source = "https://github.com/myfork/package.git"
51-
52-
1+
[[dependencies]]
2+
name = "github.com/not/used"
3+
version = "2.0.0"
534

545
[[dependencies]]
556
name = "github.com/sdboyer/deptest"
567
version = ">=0.8.0, <1.0.0"
578

589
[[dependencies]]
5910
name = "github.com/sdboyer/deptestdos"
60-
revision = "a0196baa11ea047dd65037287451d36b861b00ea"
11+
revision = "a0196baa11ea047dd65037287451d36b861b00ea"

0 commit comments

Comments
 (0)