Skip to content

Commit

Permalink
Check if project is missing from vendor during ensure
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
bradleyfalzon committed Jul 23, 2017
1 parent 167adc2 commit 23f2216
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cmd/dep/ensure.go
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,23 @@ func (cmd *ensureCommand) Run(ctx *dep.Ctx, args []string) error {
}

newLock := dep.LockFromSolution(solution)

// check if any projects are missing from vendor, if they are
// we'll need to write the vendor directory.
if writeV != dep.VendorAlways {
for _, proj := range newLock.Projects() {
projVendorPath := filepath.Join(p.AbsRoot, "vendor", string(proj.Ident().ProjectRoot))
projInVendor, err := fs.IsNonEmptyDir(projVendorPath)
if err != nil {
return errors.Wrapf(err, "ensure %v is a directory or remove it")
}
if !projInVendor {
writeV = dep.VendorAlways
break
}
}
}

sw, err := dep.NewSafeWriter(nil, p.Lock, newLock, writeV)
if err != nil {
return err
Expand Down

0 comments on commit 23f2216

Please sign in to comment.