commit 64e1613fb390bd893900dc0596e5c3f3c8e1cd8c
parent b959ecbc8175e2bf260f10b08965531bce9bcb7e
Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Mon, 25 Oct 2021 12:18:00 +0200
Fix panic when specifying multiple excludeFiles directives
Fixes #9076
Diffstat:
3 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/hugolib/mount_filters_test.go b/hugolib/mount_filters_test.go
@@ -62,7 +62,7 @@ includeFiles = "/mydata/**"
[[module.mounts]]
source = 'assets'
target = 'assets'
-excludeFiles = "/**exclude.*"
+excludeFiles = ["/**exclude.*", "/moooo.*"]
[[module.mounts]]
source = 'i18n'
target = 'i18n'
diff --git a/modules/collect.go b/modules/collect.go
@@ -149,13 +149,13 @@ func (m *ModulesConfig) finalize(logger loggers.Logger) error {
func filterUnwantedMounts(mounts []Mount) []Mount {
// Remove duplicates
- seen := make(map[Mount]bool)
+ seen := make(map[string]bool)
tmp := mounts[:0]
for _, m := range mounts {
- if !seen[m] {
+ if !seen[m.key()] {
tmp = append(tmp, m)
}
- seen[m] = true
+ seen[m.key()] = true
}
return tmp
}
diff --git a/modules/config.go b/modules/config.go
@@ -15,6 +15,7 @@ package modules
import (
"fmt"
+ "path"
"path/filepath"
"strings"
@@ -386,6 +387,11 @@ type Mount struct {
ExcludeFiles interface{}
}
+// Used as key to remove duplicates.
+func (m Mount) key() string {
+ return path.Join(m.Lang, m.Source, m.Target)
+}
+
func (m Mount) Component() string {
return strings.Split(m.Target, fileSeparator)[0]
}