summaryrefslogtreecommitdiffhomepage
path: root/modules
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2020-09-09 16:51:13 +0200
committerBjørn Erik Pedersen <[email protected]>2020-09-10 08:47:05 +0200
commit9a1e6d15a31ec667b2ff9cf20e43b1daca61e004 (patch)
tree1e5bfed58030989858820e3e2e1ceba0b46a31c2 /modules
parent84adecf97baa91ab18cb26812fa864b4451d3c5f (diff)
downloadhugo-9a1e6d15a31ec667b2ff9cf20e43b1daca61e004.tar.gz
hugo-9a1e6d15a31ec667b2ff9cf20e43b1daca61e004.zip
modules: Make ignoreVendor a glob pattern
Fixes #7642
Diffstat (limited to 'modules')
-rw-r--r--modules/client.go9
-rw-r--r--modules/client_test.go6
-rw-r--r--modules/collect.go5
3 files changed, 15 insertions, 5 deletions
diff --git a/modules/client.go b/modules/client.go
index c66311d05..914d06a4e 100644
--- a/modules/client.go
+++ b/modules/client.go
@@ -605,8 +605,9 @@ type ClientConfig struct {
// etc.
HookBeforeFinalize func(m *ModulesConfig) error
- // Ignore any _vendor directory.
- IgnoreVendor bool
+ // Ignore any _vendor directory for module paths matching the given pattern.
+ // This can be nil.
+ IgnoreVendor glob.Glob
// Absolute path to the project dir.
WorkingDir string
@@ -618,6 +619,10 @@ type ClientConfig struct {
ModuleConfig Config
}
+func (c ClientConfig) shouldIgnoreVendor(path string) bool {
+ return c.IgnoreVendor != nil && c.IgnoreVendor.Match(path)
+}
+
type goBinaryStatus int
type goModule struct {
diff --git a/modules/client_test.go b/modules/client_test.go
index 07b71c409..d5da621d1 100644
--- a/modules/client_test.go
+++ b/modules/client_test.go
@@ -17,6 +17,8 @@ import (
"bytes"
"testing"
+ "github.com/gohugoio/hugo/hugofs/glob"
+
"github.com/gohugoio/hugo/common/hugo"
"github.com/gohugoio/hugo/htesting"
@@ -89,7 +91,7 @@ project github.com/gohugoio/hugoTestModules1_darwin/[email protected]+vendor
Fs: hugofs.Os,
WorkingDir: workingDir,
ModuleConfig: modConfig,
- IgnoreVendor: true,
+ IgnoreVendor: globAll,
})
graphb.Reset()
@@ -101,6 +103,8 @@ project github.com/gohugoio/hugoTestModules1_darwin/[email protected]+vendor
}
+var globAll, _ = glob.GetGlob("**")
+
func TestGetModlineSplitter(t *testing.T) {
c := qt.New(t)
diff --git a/modules/collect.go b/modules/collect.go
index 0ac766fb9..f87ed2484 100644
--- a/modules/collect.go
+++ b/modules/collect.go
@@ -196,7 +196,8 @@ func (c *collector) initModules() error {
gomods: goModules{},
}
- if !c.ccfg.IgnoreVendor && c.isVendored(c.ccfg.WorkingDir) {
+ // If both these are true, we don't even need Go installed to build.
+ if c.ccfg.IgnoreVendor == nil && c.isVendored(c.ccfg.WorkingDir) {
return nil
}
@@ -229,7 +230,7 @@ func (c *collector) add(owner *moduleAdapter, moduleImport Import, disabled bool
modulePath := moduleImport.Path
var realOwner Module = owner
- if !c.ccfg.IgnoreVendor {
+ if !c.ccfg.shouldIgnoreVendor(modulePath) {
if err := c.collectModulesTXT(owner); err != nil {
return nil, err
}