diff options
author | Bjørn Erik Pedersen <[email protected]> | 2019-11-14 12:24:55 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2019-11-14 12:24:55 +0100 |
commit | 20ec9fa2bbd69dc47dfc9f1db40c954e08520071 (patch) | |
tree | 41e0cc9515ad823b8bb98ca4bb29b1f24f83bbcb /modules | |
parent | 812688fc2f3e220ac35cad9f0445a2548f0cc603 (diff) | |
download | hugo-20ec9fa2bbd69dc47dfc9f1db40c954e08520071.tar.gz hugo-20ec9fa2bbd69dc47dfc9f1db40c954e08520071.zip |
modules: Do not check for remote modules if main project is vendored
Fixes #6506
Diffstat (limited to 'modules')
-rw-r--r-- | modules/client_test.go | 6 | ||||
-rw-r--r-- | modules/collect.go | 11 |
2 files changed, 14 insertions, 3 deletions
diff --git a/modules/client_test.go b/modules/client_test.go index 8bb9df865..07b71c409 100644 --- a/modules/client_test.go +++ b/modules/client_test.go @@ -78,9 +78,9 @@ github.com/gohugoio/hugoTestModules1_darwin/[email protected] github.com/gohugoio/h 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/[email protected]+vendor -github.com/gohugoio/tests/hugo-modules-basic-test github.com/gohugoio/hugoTestModules1_darwin/[email protected]+vendor -github.com/gohugoio/tests/hugo-modules-basic-test github.com/gohugoio/hugoTestModules1_darwin/[email protected]+vendor + expectVendored := `project github.com/gohugoio/hugoTestModules1_darwin/[email protected]+vendor +project github.com/gohugoio/hugoTestModules1_darwin/[email protected]+vendor +project github.com/gohugoio/hugoTestModules1_darwin/[email protected]+vendor ` c.Assert(graphb.String(), qt.Equals, expectVendored) diff --git a/modules/collect.go b/modules/collect.go index 731a991b8..f5972a5b0 100644 --- a/modules/collect.go +++ b/modules/collect.go @@ -191,6 +191,11 @@ func (c *collector) initModules() error { 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. @@ -463,6 +468,7 @@ func (c *collector) applyThemeConfig(tc *moduleAdapter) error { } func (c *collector) collect() { + if err := c.initModules(); err != nil { c.err = err return @@ -480,6 +486,11 @@ func (c *collector) collect() { } +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 { vendorDir := filepath.Join(owner.Dir(), vendord) filename := filepath.Join(vendorDir, vendorModulesFilename) |