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

Commit

Permalink
Added flag dependent vendor behavior for ensure update as well
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin Renard committed Nov 16, 2017
1 parent c47c866 commit f7b108a
Show file tree
Hide file tree
Showing 8 changed files with 65 additions and 6 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
15 changes: 9 additions & 6 deletions cmd/dep/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
}
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 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() {
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"commands": [
["ensure", "-update", "-no-vendor"]
]
}

0 comments on commit f7b108a

Please sign in to comment.