Skip to content
This repository was archived by the owner on Sep 9, 2020. It is now read-only.

Commit 33bda2f

Browse files
authored
Merge pull request #1256 from JelteF/no-vendor-dry-run
ensure: Make -no-vendor combined with -dry-run fail when Gopkg.lock is outdated
2 parents 1d73a4a + 9db18d8 commit 33bda2f

File tree

14 files changed

+125
-0
lines changed

14 files changed

+125
-0
lines changed

CHANGELOG.md

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ NEW FEATURES:
55
* Wildcard ignore support. (#1156)
66
* Disable SourceManager lock by setting `DEPNOLOCK` environment variable.
77
(#1206)
8+
* `dep ensure -no-vendor -dry-run` now exits with an error when changes would
9+
have to be made to `Gopkg.lock`. This is useful for CI. (#1256)
810

911
BUG FIXES:
1012

cmd/dep/ensure.go

+10
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@ dep ensure -update -no-vendor
110110
111111
As above, but only modify Gopkg.lock; leave vendor/ unchanged.
112112
113+
dep ensure -no-vendor -dry-run
114+
115+
This fails with a non zero exit code if Gopkg.lock is not up to date with
116+
the Gopkg.toml or the project imports. It can be useful to run this during
117+
CI to check if Gopkg.lock is up to date.
118+
113119
`
114120

115121
var (
@@ -267,6 +273,10 @@ func (cmd *ensureCommand) runDefault(ctx *dep.Ctx, args []string, p *dep.Project
267273
return errors.WithMessage(sw.Write(p.AbsRoot, sm, true, logger), "grouped write of manifest, lock and vendor")
268274
}
269275

276+
if cmd.noVendor && cmd.dryRun {
277+
return errors.New("Gopkg.lock was not up to date")
278+
}
279+
270280
solution, err := solver.Solve()
271281
if err != nil {
272282
handleAllTheFailuresOfTheWorld(err)

cmd/dep/testdata/harness_tests/ensure/default/hasheq-novendor-dry/final/Gopkg.lock

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
[[constraint]]
3+
name = "github.com/sdboyer/deptest"
4+
version = "1.0.0"

cmd/dep/testdata/harness_tests/ensure/default/hasheq-novendor-dry/initial/Gopkg.lock

+15
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
[[constraint]]
3+
name = "github.com/sdboyer/deptest"
4+
version = "1.0.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2016 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
_ "github.com/sdboyer/deptest"
9+
)
10+
11+
func main() {
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"commands": [
3+
["ensure", "-no-vendor", "-dry-run"]
4+
]
5+
}

cmd/dep/testdata/harness_tests/ensure/default/hashneq-novendor-dry/final/Gopkg.lock

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
[[constraint]]
3+
name = "github.com/sdboyer/deptest"
4+
version = "1.0.0"

cmd/dep/testdata/harness_tests/ensure/default/hashneq-novendor-dry/initial/Gopkg.lock

+16
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
[[constraint]]
3+
name = "github.com/sdboyer/deptest"
4+
version = "1.0.0"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// Copyright 2016 The Go Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style
3+
// license that can be found in the LICENSE file.
4+
5+
package main
6+
7+
import (
8+
_ "github.com/sdboyer/deptest"
9+
)
10+
11+
func main() {
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commands": [
3+
["ensure", "-no-vendor", "-dry-run"]
4+
],
5+
"error-expected": "Gopkg.lock was not up to date"
6+
}

0 commit comments

Comments
 (0)