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

Commit 0679151

Browse files
committed
ensure: always write vendor even if not empty
If the vendor directory already exists, and the lock file hasn't changed, even though a project may be missing from the vendor directory, dep ensure would not add the dependency to the vendor folder. If the project is in the vendor folder, but it has been modified (no longer in sync with lock file), ensure would not replace the dependency in the vendor folder. This change causes dep ensure to run anytime there's a solution, regardless of the state vendor folder is in, erring on the side of replacing vendor without checking existing state which is the most correct behaviour given the ensure intention. Future optimisations may want to check and verify the contents of the vendor folder before blinding replacing it.
1 parent 167adc2 commit 0679151

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

cmd/dep/ensure.go

+1-9
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,9 @@ import (
1010
"fmt"
1111
"go/build"
1212
"log"
13-
"path/filepath"
1413
"strings"
1514

1615
"github.com/golang/dep"
17-
"github.com/golang/dep/internal/fs"
1816
"github.com/golang/dep/internal/gps"
1917
"github.com/golang/dep/internal/gps/pkgtree"
2018
"github.com/pkg/errors"
@@ -151,14 +149,8 @@ func (cmd *ensureCommand) Run(ctx *dep.Ctx, args []string) error {
151149
return errors.Wrap(err, "ensure Solve()")
152150
}
153151

154-
// check if vendor exists, because if the locks are the same but
155-
// vendor does not exist we should write vendor
156-
vendorExists, err := fs.IsNonEmptyDir(filepath.Join(p.AbsRoot, "vendor"))
157-
if err != nil {
158-
return errors.Wrap(err, "ensure vendor is a directory")
159-
}
160152
writeV := dep.VendorOnChanged
161-
if !vendorExists && solution != nil {
153+
if solution != nil {
162154
writeV = dep.VendorAlways
163155
}
164156

0 commit comments

Comments
 (0)