Skip to content

Commit

Permalink
modules: Do not check for remote modules if main project is vendored
Browse files Browse the repository at this point in the history
  • Loading branch information
bep committed Nov 14, 2019
1 parent 812688f commit 20ec9fa
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 3 additions & 3 deletions modules/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ github.com/gohugoio/hugoTestModules1_darwin/modh2_2@v1.4.0 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/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)

Expand Down
11 changes: 11 additions & 0 deletions modules/collect.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down

0 comments on commit 20ec9fa

Please sign in to comment.