ref: 20ec9fa2bbd69dc47dfc9f1db40c954e08520071
parent: 812688fc2f3e220ac35cad9f0445a2548f0cc603
author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
date: Thu Nov 14 07:24:55 EST 2019
modules: Do not check for remote modules if main project is vendored Fixes #6506
--- a/modules/client_test.go
+++ b/modules/client_test.go
@@ -78,9 +78,9 @@
c.Assert(client.Vendor(), qt.IsNil)
graphb.Reset()
c.Assert(client.Graph(&graphb), qt.IsNil)
- expectVendored := `github.com/gohugoio/tests/hugo-modules-basic-test github.com/gohugoio/hugoTestModules1_darwin/modh2_2@v1.4.0+vendor
-github.com/gohugoio/tests/hugo-modules-basic-test github.com/gohugoio/hugoTestModules1_darwin/modh2_2_1v@v1.3.0+vendor
-github.com/gohugoio/tests/hugo-modules-basic-test github.com/gohugoio/hugoTestModules1_darwin/modh2_2_2@v1.3.0+vendor
+ expectVendored := `project github.com/gohugoio/hugoTestModules1_darwin/modh2_2@v1.4.0+vendor
+project github.com/gohugoio/hugoTestModules1_darwin/modh2_2_1v@v1.3.0+vendor
+project github.com/gohugoio/hugoTestModules1_darwin/modh2_2_2@v1.3.0+vendor
`
c.Assert(graphb.String(), qt.Equals, expectVendored)
--- a/modules/collect.go
+++ b/modules/collect.go
@@ -191,8 +191,13 @@
c.collected = &collected{
seen: make(map[string]bool),
vendored: make(map[string]vendoredModule),
+ gomods: goModules{},
}
+ if !c.ccfg.IgnoreVendor && c.isVendored(c.ccfg.WorkingDir) {
+ return nil
+ }
+
// We may fail later if we don't find the mods.
return c.loadModules()
}
@@ -463,6 +468,7 @@
}
func (c *collector) collect() {
+
if err := c.initModules(); err != nil {
c.err = err
return
@@ -478,6 +484,11 @@
// Add the project mod on top.
c.modules = append(Modules{projectMod}, c.modules...)
+}
+
+func (c *collector) isVendored(dir string) bool {
+ _, err := c.fs.Stat(filepath.Join(dir, vendord, vendorModulesFilename))
+ return err == nil
}
func (c *collector) collectModulesTXT(owner Module) error {