aboutsummaryrefslogtreecommitdiffhomepage
path: root/hugolib
diff options
context:
space:
mode:
authorBjørn Erik Pedersen <[email protected]>2024-11-04 10:31:59 +0100
committerBjørn Erik Pedersen <[email protected]>2024-11-04 12:44:07 +0100
commitfcdc454cc58e9f26ba29389100adfc09cb383448 (patch)
tree1d66ea84f966549b51ada9a74cc40c4e4ac69c59 /hugolib
parent6cf23bf8824758b0d2c4d855f0241e72aef77206 (diff)
downloadhugo-fcdc454cc58e9f26ba29389100adfc09cb383448.tar.gz
hugo-fcdc454cc58e9f26ba29389100adfc09cb383448.zip
Do not watch directories with no mounted files in it
Fixes #12912 Fixes #13007
Diffstat (limited to 'hugolib')
-rw-r--r--hugolib/filesystems/basefs_test.go33
1 files changed, 30 insertions, 3 deletions
diff --git a/hugolib/filesystems/basefs_test.go b/hugolib/filesystems/basefs_test.go
index e39709386..3f189c860 100644
--- a/hugolib/filesystems/basefs_test.go
+++ b/hugolib/filesystems/basefs_test.go
@@ -220,6 +220,18 @@ target = 'content'
source = 'content2'
target = 'content/c2'
[[module.mounts]]
+source = 'content3'
+target = 'content/watchdisabled'
+disableWatch = true
+[[module.mounts]]
+source = 'content4'
+target = 'content/excludedsome'
+excludeFiles = 'p1.md'
+[[module.mounts]]
+source = 'content5'
+target = 'content/excludedall'
+excludeFiles = '/**'
+[[module.mounts]]
source = "hugo_stats.json"
target = "assets/watching/hugo_stats.json"
-- hugo_stats.json --
@@ -230,12 +242,27 @@ foo
-- themes/t1/layouts/_default/single.html --
{{ .Content }}
-- themes/t1/static/f1.txt --
+-- content3/p1.md --
+-- content4/p1.md --
+-- content4/p2.md --
+-- content5/p3.md --
+-- content5/p4.md --
`
b := hugolib.Test(t, files)
bfs := b.H.BaseFs
- watchFilenames := bfs.WatchFilenames()
- // []string{"/hugo_stats.json", "/content", "/content2", "/themes/t1/layouts", "/themes/t1/layouts/_default", "/themes/t1/static"}
- b.Assert(watchFilenames, qt.HasLen, 6)
+ watchFilenames := toSlashes(bfs.WatchFilenames())
+
+ // content3 has disableWatch = true
+ // content5 has excludeFiles = '/**'
+ b.Assert(watchFilenames, qt.DeepEquals, []string{"/hugo_stats.json", "/content", "/content2", "/content4", "/themes/t1/layouts", "/themes/t1/layouts/_default", "/themes/t1/static"})
+}
+
+func toSlashes(in []string) []string {
+ out := make([]string, len(in))
+ for i, s := range in {
+ out[i] = filepath.ToSlash(s)
+ }
+ return out
}
func TestNoSymlinks(t *testing.T) {