hugofs: Add includeFiles and excludeFiles to mount configuration

Fixes #9042
This commit is contained in:
Bjørn Erik Pedersen
2021-10-16 16:24:49 +02:00
parent 94a5bac5b2
commit 471ed91c60
15 changed files with 797 additions and 133 deletions

View File

@@ -23,6 +23,8 @@ import (
"strings"
"time"
"github.com/gohugoio/hugo/hugofs/glob"
"github.com/gohugoio/hugo/hugofs/files"
"golang.org/x/text/unicode/norm"
@@ -76,6 +78,9 @@ type FileMeta struct {
Fs afero.Fs
OpenFunc func() (afero.File, error)
JoinStatFunc func(name string) (FileMetaInfo, error)
// Include only files or directories that match.
InclusionFilter *glob.FilenameFilter
}
func (m *FileMeta) Copy() *FileMeta {
@@ -95,10 +100,17 @@ func (m *FileMeta) Merge(from *FileMeta) {
for i := 0; i < dstv.NumField(); i++ {
v := dstv.Field(i)
if !v.CanSet() {
continue
}
if !hreflect.IsTruthfulValue(v) {
v.Set(srcv.Field(i))
}
}
if m.InclusionFilter == nil {
m.InclusionFilter = from.InclusionFilter
}
}
func (f *FileMeta) Open() (afero.File, error) {