mirror of
https://github.com/gohugoio/hugo.git
synced 2024-11-21 20:46:30 -05:00
Fix sample logic when adding content files in server
The partial rebuilds works by calaulating a baseline from a change set. For new content, this doesn't work, so to avoid rebuilding everything, we first try to collect a sample of surrounding identities (e.g. content files in the same section). This commit fixes a flaw in that logic that in some (many...) cases would return a too small sample set. Fixes #12054
This commit is contained in:
parent
168d375784
commit
afe5b6d7df
2 changed files with 24 additions and 1 deletions
|
@ -192,7 +192,7 @@ func (t *pageTrees) collectIdentitiesSurroundingIn(key string, maxSamples int, t
|
||||||
level := strings.Count(prefix, "/")
|
level := strings.Count(prefix, "/")
|
||||||
tree.WalkPrefixRaw(prefix, func(s string, n contentNodeI) bool {
|
tree.WalkPrefixRaw(prefix, func(s string, n contentNodeI) bool {
|
||||||
if level != strings.Count(s, "/") {
|
if level != strings.Count(s, "/") {
|
||||||
return true
|
return false
|
||||||
}
|
}
|
||||||
n.ForEeachIdentity(func(id identity.Identity) bool {
|
n.ForEeachIdentity(func(id identity.Identity) bool {
|
||||||
ids = append(ids, id)
|
ids = append(ids, id)
|
||||||
|
|
|
@ -261,6 +261,29 @@ func TestRebuilErrorRecovery(t *testing.T) {
|
||||||
b.EditFileReplaceAll("content/mysection/mysectionbundle/index.md", "{{< foo }}", "{{< foo >}}").Build()
|
b.EditFileReplaceAll("content/mysection/mysectionbundle/index.md", "{{< foo }}", "{{< foo >}}").Build()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestRebuildAddPageListPagesInHome(t *testing.T) {
|
||||||
|
files := `
|
||||||
|
-- hugo.toml --
|
||||||
|
baseURL = "https://example.com"
|
||||||
|
disableLiveReload = true
|
||||||
|
-- content/asection/s1.md --
|
||||||
|
-- content/p1.md --
|
||||||
|
---
|
||||||
|
title: "P1"
|
||||||
|
weight: 1
|
||||||
|
---
|
||||||
|
-- layouts/_default/single.html --
|
||||||
|
Single: {{ .Title }}|{{ .Content }}|
|
||||||
|
-- layouts/index.html --
|
||||||
|
Pages: {{ range .RegularPages }}{{ .RelPermalink }}|{{ end }}$
|
||||||
|
`
|
||||||
|
|
||||||
|
b := TestRunning(t, files)
|
||||||
|
b.AssertFileContent("public/index.html", "Pages: /p1/|$")
|
||||||
|
b.AddFiles("content/p2.md", ``).Build()
|
||||||
|
b.AssertFileContent("public/index.html", "Pages: /p1/|/p2/|$")
|
||||||
|
}
|
||||||
|
|
||||||
func TestRebuildScopedToOutputFormat(t *testing.T) {
|
func TestRebuildScopedToOutputFormat(t *testing.T) {
|
||||||
files := `
|
files := `
|
||||||
-- hugo.toml --
|
-- hugo.toml --
|
||||||
|
|
Loading…
Reference in a new issue