diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-02-09 13:52:36 +0200 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-02-16 13:17:53 +0100 |
commit | 639073e4fee8fd4235c1002b076e110fad4c82f2 (patch) | |
tree | 55f4c392bc4f156f8605993d3d416bd5b105cc40 /hugolib | |
parent | 21d9057dbfe64f668d5fc6a7f458e0984fbf7e56 (diff) | |
download | hugo-639073e4fee8fd4235c1002b076e110fad4c82f2.tar.gz hugo-639073e4fee8fd4235c1002b076e110fad4c82f2.zip |
Fix rebuild with resources.Concat
Fixes #12017
Diffstat (limited to 'hugolib')
-rw-r--r-- | hugolib/content_map.go | 9 | ||||
-rw-r--r-- | hugolib/content_map_page.go | 11 | ||||
-rw-r--r-- | hugolib/page.go | 4 | ||||
-rw-r--r-- | hugolib/page__new.go | 9 | ||||
-rw-r--r-- | hugolib/page__output.go | 7 | ||||
-rw-r--r-- | hugolib/rebuild_test.go | 34 |
6 files changed, 49 insertions, 25 deletions
diff --git a/hugolib/content_map.go b/hugolib/content_map.go index 85300e3db..23b74e1c7 100644 --- a/hugolib/content_map.go +++ b/hugolib/content_map.go @@ -93,8 +93,8 @@ func (r *resourceSource) GetIdentity() identity.Identity { return r.path } -func (r *resourceSource) ForEeachIdentity(f func(identity.Identity) bool) { - f(r.GetIdentity()) +func (r *resourceSource) ForEeachIdentity(f func(identity.Identity) bool) bool { + return f(r.GetIdentity()) } func (r *resourceSource) Path() string { @@ -142,14 +142,15 @@ func (n resourceSources) GetIdentity() identity.Identity { return nil } -func (n resourceSources) ForEeachIdentity(f func(identity.Identity) bool) { +func (n resourceSources) ForEeachIdentity(f func(identity.Identity) bool) bool { for _, r := range n { if r != nil { if f(r.GetIdentity()) { - return + return true } } } + return false } func (cfg contentMapConfig) getTaxonomyConfig(s string) (v viewName) { diff --git a/hugolib/content_map_page.go b/hugolib/content_map_page.go index 6273870b7..576ee5e08 100644 --- a/hugolib/content_map_page.go +++ b/hugolib/content_map_page.go @@ -605,12 +605,15 @@ func (n contentNodeIs) GetIdentity() identity.Identity { return n[0].GetIdentity() } -func (n contentNodeIs) ForEeachIdentity(f func(identity.Identity) bool) { +func (n contentNodeIs) ForEeachIdentity(f func(identity.Identity) bool) bool { for _, nn := range n { if nn != nil { - nn.ForEeachIdentity(f) + if nn.ForEeachIdentity(f) { + return true + } } } + return false } func (n contentNodeIs) resetBuildState() { @@ -1151,7 +1154,7 @@ func (h *HugoSites) resolveAndResetDependententPageOutputs(ctx context.Context, // First check the top level dependency manager. for _, id := range changes { checkedCounter.Add(1) - if r := depsFinder.Contains(id, p.dependencyManager, 100); r > identity.FinderFoundOneOfManyRepetition { + if r := depsFinder.Contains(id, p.dependencyManager, 2); r > identity.FinderFoundOneOfManyRepetition { for _, po := range p.pageOutputs { resetPo(po, r) } @@ -1167,7 +1170,7 @@ func (h *HugoSites) resolveAndResetDependententPageOutputs(ctx context.Context, } for _, id := range changes { checkedCounter.Add(1) - if r := depsFinder.Contains(id, po.dependencyManagerOutput, 2); r > identity.FinderFoundOneOfManyRepetition { + if r := depsFinder.Contains(id, po.dependencyManagerOutput, 50); r > identity.FinderFoundOneOfManyRepetition { resetPo(po, r) continue OUTPUTS } diff --git a/hugolib/page.go b/hugolib/page.go index 10ecdcad2..c743d4282 100644 --- a/hugolib/page.go +++ b/hugolib/page.go @@ -120,8 +120,8 @@ func (p *pageState) GetIdentity() identity.Identity { return p } -func (p *pageState) ForEeachIdentity(f func(identity.Identity) bool) { - f(p) +func (p *pageState) ForEeachIdentity(f func(identity.Identity) bool) bool { + return f(p) } func (p *pageState) GetDependencyManager() identity.Manager { diff --git a/hugolib/page__new.go b/hugolib/page__new.go index 2c2d92ab8..9dd2f2cdf 100644 --- a/hugolib/page__new.go +++ b/hugolib/page__new.go @@ -20,7 +20,6 @@ import ( "sync/atomic" "github.com/gohugoio/hugo/hugofs/files" - "github.com/gohugoio/hugo/identity" "github.com/gohugoio/hugo/resources" "github.com/gohugoio/hugo/common/maps" @@ -160,12 +159,6 @@ func (h *HugoSites) newPage(m *pageMeta) (*pageState, *paths.Path, error) { return nil, nil } - var dependencyManager identity.Manager = identity.NopManager - - if m.s.conf.Internal.Watch { - dependencyManager = identity.NewManager(m.Path()) - } - // Parse the rest of the page content. m.content, err = m.newCachedContent(h, pi) if err != nil { @@ -178,7 +171,7 @@ func (h *HugoSites) newPage(m *pageMeta) (*pageState, *paths.Path, error) { pageOutputTemplateVariationsState: &atomic.Uint32{}, resourcesPublishInit: &sync.Once{}, Staler: m, - dependencyManager: dependencyManager, + dependencyManager: m.s.Conf.NewIdentityManager(m.Path()), pageCommon: &pageCommon{ FileProvider: m, AuthorProvider: m, diff --git a/hugolib/page__output.go b/hugolib/page__output.go index 9050766d1..2f4d6c205 100644 --- a/hugolib/page__output.go +++ b/hugolib/page__output.go @@ -51,11 +51,6 @@ func newPageOutput( }) } - var dependencyManager identity.Manager = identity.NopManager - if ps.s.conf.Internal.Watch { - dependencyManager = identity.NewManager(ps.Path() + "/" + f.Name) - } - providers := struct { page.PaginatorProvider resource.ResourceLinksProvider @@ -75,7 +70,7 @@ func newPageOutput( TableOfContentsProvider: page.NopPage, render: render, paginator: pag, - dependencyManagerOutput: dependencyManager, + dependencyManagerOutput: ps.s.Conf.NewIdentityManager((ps.Path() + "/" + f.Name)), } return po diff --git a/hugolib/rebuild_test.go b/hugolib/rebuild_test.go index b1ebe14d5..9b15fc3e2 100644 --- a/hugolib/rebuild_test.go +++ b/hugolib/rebuild_test.go @@ -1131,7 +1131,7 @@ Single. Running: true, NeedsOsFS: true, NeedsNpmInstall: true, - // LogLevel: logg.LevelTrace, + // LogLevel: logg.LevelDebug, }, ).Build() @@ -1261,3 +1261,35 @@ func BenchmarkRebuildContentFileChange(b *testing.B) { // fmt.Println(bb.LogString()) } } + +func TestRebuildConcat(t *testing.T) { + files := ` +-- hugo.toml -- +baseURL = "https://example.com" +disableLiveReload = true +disableKinds = ["taxonomy", "term", "sitemap", "robotsTXT", "404", "rss"] +-- assets/a.css -- +a +-- assets/b.css -- +b +-- assets/c.css -- +c +-- assets/common/c1.css -- +c1 +-- assets/common/c2.css -- +c2 +-- layouts/index.html -- +{{ $a := resources.Get "a.css" }} +{{ $b := resources.Get "b.css" }} +{{ $common := resources.Match "common/*.css" | resources.Concat "common.css" | minify }} +{{ $ab := slice $a $b $common | resources.Concat "ab.css" }} +all: {{ $ab.RelPermalink }} +` + b := TestRunning(t, files) + + b.AssertFileContent("public/ab.css", "abc1c2") + b.EditFileReplaceAll("assets/common/c2.css", "c2", "c2 edited").Build() + b.AssertFileContent("public/ab.css", "abc1c2 edited") + b.AddFiles("assets/common/c3.css", "c3").Build() + b.AssertFileContent("public/ab.css", "abc1c2 editedc3") +} |