Skip to content

Commit 23f2216

Browse files
committed
Check if project is missing from vendor during ensure
If a 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 it. This change checks if we're not already writing the vendor directory whether any of the projects are missing from the vendor directory and if they are, ensures the writer writes out the vendor directory. Fixes golang#883.
1 parent 167adc2 commit 23f2216

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

cmd/dep/ensure.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,23 @@ func (cmd *ensureCommand) Run(ctx *dep.Ctx, args []string) error {
163163
}
164164

165165
newLock := dep.LockFromSolution(solution)
166+
167+
// check if any projects are missing from vendor, if they are
168+
// we'll need to write the vendor directory.
169+
if writeV != dep.VendorAlways {
170+
for _, proj := range newLock.Projects() {
171+
projVendorPath := filepath.Join(p.AbsRoot, "vendor", string(proj.Ident().ProjectRoot))
172+
projInVendor, err := fs.IsNonEmptyDir(projVendorPath)
173+
if err != nil {
174+
return errors.Wrapf(err, "ensure %v is a directory or remove it")
175+
}
176+
if !projInVendor {
177+
writeV = dep.VendorAlways
178+
break
179+
}
180+
}
181+
}
182+
166183
sw, err := dep.NewSafeWriter(nil, p.Lock, newLock, writeV)
167184
if err != nil {
168185
return err

0 commit comments

Comments
 (0)