diff --git a/CHANGELOG.md b/CHANGELOG.md index d66dc79222..1985fb8133 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ BUG FIXES: * Releases targeting Windows now have a `.exe` suffix (#1291). * Adaptively recover from dirty and corrupted git repositories in cache (#1279). +* Fix `-no-vendor` flag for `ensure -update` ([#1361](https://github.com/golang/dep/pull/1361)) IMPROVEMENTS: diff --git a/cmd/dep/ensure.go b/cmd/dep/ensure.go index 1a5cc465c2..07157b14b5 100644 --- a/cmd/dep/ensure.go +++ b/cmd/dep/ensure.go @@ -226,6 +226,13 @@ func (cmd *ensureCommand) validateFlags() error { return nil } +func (cmd *ensureCommand) vendorBehavior() dep.VendorBehavior { + if cmd.noVendor { + return dep.VendorNever + } + return dep.VendorOnChanged +} + func (cmd *ensureCommand) runDefault(ctx *dep.Ctx, args []string, p *dep.Project, sm gps.SourceManager, params gps.SolveParameters) error { // Bare ensure doesn't take any args. if len(args) != 0 { @@ -283,11 +290,7 @@ func (cmd *ensureCommand) runDefault(ctx *dep.Ctx, args []string, p *dep.Project return handleAllTheFailuresOfTheWorld(err) } - vendorBehavior := dep.VendorOnChanged - if cmd.noVendor { - vendorBehavior = dep.VendorNever - } - sw, err := dep.NewSafeWriter(nil, p.Lock, dep.LockFromSolution(solution), vendorBehavior) + sw, err := dep.NewSafeWriter(nil, p.Lock, dep.LockFromSolution(solution), cmd.vendorBehavior()) if err != nil { return err } @@ -377,7 +380,7 @@ func (cmd *ensureCommand) runUpdate(ctx *dep.Ctx, args []string, p *dep.Project, return handleAllTheFailuresOfTheWorld(err) } - sw, err := dep.NewSafeWriter(nil, p.Lock, dep.LockFromSolution(solution), dep.VendorOnChanged) + sw, err := dep.NewSafeWriter(nil, p.Lock, dep.LockFromSolution(solution), cmd.vendorBehavior()) if err != nil { return err } diff --git a/cmd/dep/testdata/harness_tests/ensure/update/novendor/final/Gopkg.lock b/cmd/dep/testdata/harness_tests/ensure/update/novendor/final/Gopkg.lock new file mode 100644 index 0000000000..c7f497e7a1 --- /dev/null +++ b/cmd/dep/testdata/harness_tests/ensure/update/novendor/final/Gopkg.lock @@ -0,0 +1,15 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + name = "github.com/sdboyer/deptest" + packages = ["."] + revision = "ff2948a2ac8f538c4ecd55962e919d1e13e74baf" + version = "v1.0.0" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + inputs-digest = "14b07b05e0f01051b03887ab2bf80b516bc5510ea92f75f76c894b1745d8850c" + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/cmd/dep/testdata/harness_tests/ensure/update/novendor/final/Gopkg.toml b/cmd/dep/testdata/harness_tests/ensure/update/novendor/final/Gopkg.toml new file mode 100644 index 0000000000..e242e02114 --- /dev/null +++ b/cmd/dep/testdata/harness_tests/ensure/update/novendor/final/Gopkg.toml @@ -0,0 +1,4 @@ + +[[constraint]] + name = "github.com/sdboyer/deptest" + version = "1.0.0" diff --git a/cmd/dep/testdata/harness_tests/ensure/update/novendor/initial/Gopkg.lock b/cmd/dep/testdata/harness_tests/ensure/update/novendor/initial/Gopkg.lock new file mode 100644 index 0000000000..810f1b0316 --- /dev/null +++ b/cmd/dep/testdata/harness_tests/ensure/update/novendor/initial/Gopkg.lock @@ -0,0 +1,15 @@ +# This file is autogenerated, do not edit; changes may be undone by the next 'dep ensure'. + + +[[projects]] + name = "github.com/sdboyer/deptest" + packages = ["."] + revision = "3f4c3bea144e112a69bbe5d8d01c1b09a544253f" + version = "v0.8.1" + +[solve-meta] + analyzer-name = "dep" + analyzer-version = 1 + inputs-digest = "14b07b05e0f01051b03887ab2bf80b516bc5510ea92f75f76c894b1745d8850c" + solver-name = "gps-cdcl" + solver-version = 1 diff --git a/cmd/dep/testdata/harness_tests/ensure/update/novendor/initial/Gopkg.toml b/cmd/dep/testdata/harness_tests/ensure/update/novendor/initial/Gopkg.toml new file mode 100644 index 0000000000..e242e02114 --- /dev/null +++ b/cmd/dep/testdata/harness_tests/ensure/update/novendor/initial/Gopkg.toml @@ -0,0 +1,4 @@ + +[[constraint]] + name = "github.com/sdboyer/deptest" + version = "1.0.0" diff --git a/cmd/dep/testdata/harness_tests/ensure/update/novendor/initial/main.go b/cmd/dep/testdata/harness_tests/ensure/update/novendor/initial/main.go new file mode 100644 index 0000000000..e23fcf34c5 --- /dev/null +++ b/cmd/dep/testdata/harness_tests/ensure/update/novendor/initial/main.go @@ -0,0 +1,12 @@ +// Copyright 2017 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() { +} diff --git a/cmd/dep/testdata/harness_tests/ensure/update/novendor/testcase.json b/cmd/dep/testdata/harness_tests/ensure/update/novendor/testcase.json new file mode 100644 index 0000000000..518f5efbec --- /dev/null +++ b/cmd/dep/testdata/harness_tests/ensure/update/novendor/testcase.json @@ -0,0 +1,5 @@ +{ + "commands": [ + ["ensure", "-update", "-no-vendor"] + ] +}