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

Commit

Permalink
Merge pull request #1256 from JelteF/no-vendor-dry-run
Browse files Browse the repository at this point in the history
ensure: Make -no-vendor combined with -dry-run fail when Gopkg.lock is outdated
  • Loading branch information
sdboyer authored Oct 17, 2017
2 parents 1d73a4a + 9db18d8 commit 33bda2f
Show file tree
Hide file tree
Showing 14 changed files with 125 additions and 0 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ NEW FEATURES:
* Wildcard ignore support. (#1156)
* Disable SourceManager lock by setting `DEPNOLOCK` environment variable.
(#1206)
* `dep ensure -no-vendor -dry-run` now exits with an error when changes would
have to be made to `Gopkg.lock`. This is useful for CI. (#1256)

BUG FIXES:

Expand Down
10 changes: 10 additions & 0 deletions cmd/dep/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,12 @@ dep ensure -update -no-vendor
As above, but only modify Gopkg.lock; leave vendor/ unchanged.
dep ensure -no-vendor -dry-run
This fails with a non zero exit code if Gopkg.lock is not up to date with
the Gopkg.toml or the project imports. It can be useful to run this during
CI to check if Gopkg.lock is up to date.
`

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

if cmd.noVendor && cmd.dryRun {
return errors.New("Gopkg.lock was not up to date")
}

solution, err := solver.Solve()
if err != nil {
handleAllTheFailuresOfTheWorld(err)
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[[constraint]]
name = "github.com/sdboyer/deptest"
version = "1.0.0"

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[[constraint]]
name = "github.com/sdboyer/deptest"
version = "1.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
_ "github.com/sdboyer/deptest"
)

func main() {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"commands": [
["ensure", "-no-vendor", "-dry-run"]
]
}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[[constraint]]
name = "github.com/sdboyer/deptest"
version = "1.0.0"

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

[[constraint]]
name = "github.com/sdboyer/deptest"
version = "1.0.0"
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
// Copyright 2016 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.

package main

import (
_ "github.com/sdboyer/deptest"
)

func main() {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"commands": [
["ensure", "-no-vendor", "-dry-run"]
],
"error-expected": "Gopkg.lock was not up to date"
}

0 comments on commit 33bda2f

Please sign in to comment.