summaryrefslogtreecommitdiffstats
path: root/hugolib/filesystems
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-03-20 11:24:44 +0100
committerBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>2022-03-20 20:23:03 +0100
commit1c0e7c1ae1eb9cd47fbe030ebddbf89df04fe667 (patch)
treee3e5528048ddb5bb749e7549eb8946717ebd45a3 /hugolib/filesystems
parentcad2d8cc70f25ca5e5107dd963c95b7b7c6840d1 (diff)
Make sure file mounts higher up wins
Fixes #9693
Diffstat (limited to 'hugolib/filesystems')
-rw-r--r--hugolib/filesystems/basefs.go12
1 files changed, 7 insertions, 5 deletions
diff --git a/hugolib/filesystems/basefs.go b/hugolib/filesystems/basefs.go
index 2e32932c6..6e3f88a4b 100644
--- a/hugolib/filesystems/basefs.go
+++ b/hugolib/filesystems/basefs.go
@@ -602,6 +602,7 @@ func (b *sourceFilesystemsBuilder) createMainOverlayFs(p *paths.Paths) (*filesys
Module: mod,
dir: dir,
isMainProject: isMainProject,
+ ordinal: j,
}
j++
}
@@ -635,12 +636,12 @@ func (b *sourceFilesystemsBuilder) createModFs(
return md.dir, paths.AbsPathify(md.dir, path)
}
- for _, mount := range md.Mounts() {
+ for i, mount := range md.Mounts() {
- mountWeight := 1
- if md.isMainProject {
- mountWeight++
- }
+ // Add more weight to early mounts.
+ // When two mounts contain the same filename,
+ // the first entry wins.
+ mountWeight := (10 + md.ordinal) * (len(md.Mounts()) - i)
inclusionFilter, err := glob.NewFilenameFilter(
types.ToStringSlicePreserveString(mount.IncludeFiles),
@@ -829,6 +830,7 @@ type mountsDescriptor struct {
modules.Module
dir string
isMainProject bool
+ ordinal int
}
func (b *sourceFilesystemsBuilder) createOverlayFs(collector *filesystemsCollector, mounts []mountsDescriptor) error {