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

Commit f7b108a

Browse files
author
Quentin Renard
committed
Added flag dependent vendor behavior for ensure update as well
1 parent c47c866 commit f7b108a

File tree

8 files changed

+65
-6
lines changed

8 files changed

+65
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ BUG FIXES:
44

55
* Releases targeting Windows now have a `.exe` suffix (#1291).
66
* Adaptively recover from dirty and corrupted git repositories in cache (#1279).
7+
* Fix `-no-vendor` flag for `ensure -update` ([#1361](https://github.com/golang/dep/pull/1361))
78

89
IMPROVEMENTS:
910

cmd/dep/ensure.go

+9-6
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,13 @@ func (cmd *ensureCommand) validateFlags() error {
226226
return nil
227227
}
228228

229+
func (cmd *ensureCommand) vendorBehavior() dep.VendorBehavior {
230+
if cmd.noVendor {
231+
return dep.VendorNever
232+
}
233+
return dep.VendorOnChanged
234+
}
235+
229236
func (cmd *ensureCommand) runDefault(ctx *dep.Ctx, args []string, p *dep.Project, sm gps.SourceManager, params gps.SolveParameters) error {
230237
// Bare ensure doesn't take any args.
231238
if len(args) != 0 {
@@ -283,11 +290,7 @@ func (cmd *ensureCommand) runDefault(ctx *dep.Ctx, args []string, p *dep.Project
283290
return handleAllTheFailuresOfTheWorld(err)
284291
}
285292

286-
vendorBehavior := dep.VendorOnChanged
287-
if cmd.noVendor {
288-
vendorBehavior = dep.VendorNever
289-
}
290-
sw, err := dep.NewSafeWriter(nil, p.Lock, dep.LockFromSolution(solution), vendorBehavior)
293+
sw, err := dep.NewSafeWriter(nil, p.Lock, dep.LockFromSolution(solution), cmd.vendorBehavior())
291294
if err != nil {
292295
return err
293296
}
@@ -377,7 +380,7 @@ func (cmd *ensureCommand) runUpdate(ctx *dep.Ctx, args []string, p *dep.Project,
377380
return handleAllTheFailuresOfTheWorld(err)
378381
}
379382

380-
sw, err := dep.NewSafeWriter(nil, p.Lock, dep.LockFromSolution(solution), dep.VendorOnChanged)
383+
sw, err := dep.NewSafeWriter(nil, p.Lock, dep.LockFromSolution(solution), cmd.vendorBehavior())
381384
if err != nil {
382385
return err
383386
}

cmd/dep/testdata/harness_tests/ensure/update/novendor/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/update/novendor/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 2017 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", "-update", "-no-vendor"]
4+
]
5+
}

0 commit comments

Comments
 (0)