From ddef3b2d67ddeb1076fb070910630904c82d6276 Mon Sep 17 00:00:00 2001 From: Quentin Renard Date: Thu, 9 Nov 2017 11:46:03 +0100 Subject: [PATCH] Added flag dependent vendor behavior for ensure update as well --- cmd/dep/ensure.go | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) 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 }