From: Bjørn Erik Pedersen Date: Fri, 23 Jan 2026 15:08:29 +0000 (+0100) Subject: Fix cascade draft panic X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=11f7f39913d56291f0e049f674378da06cfd4e70;p=brevno-suite%2Fhugo Fix cascade draft panic Fixes #14409 Fixes #14412 Co-authored-by: Joe Mooring --- diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index b8670cb4d..91af1538e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -106,7 +106,10 @@ jobs: run: go install honnef.co/go/tools/cmd/staticcheck@latest - if: matrix.os == 'ubuntu-latest' name: Run staticcheck - run: staticcheck ./... + run: | + export STATICCHECK_CACHE="${{ runner.temp }}/staticcheck" + staticcheck ./... + rm -rf ${{ runner.temp }}/staticcheck - if: matrix.os != 'windows-latest' name: Check run: | @@ -118,16 +121,15 @@ jobs: # See issue #11052. We limit the build to regular test (no -race flag) on Windows for now. name: Test run: | - mage -v test; + mage -v test + go clean -i -testcache env: HUGO_BUILD_TAGS: extended,withdeploy - - name: Build tags - run: | - go install -tags extended - if: matrix.os == 'ubuntu-latest' name: Build for dragonfly run: | go install + go clean -i -cache env: GOARCH: amd64 GOOS: dragonfly diff --git a/hugolib/cascade_test.go b/hugolib/cascade_test.go index 660093599..8eaa369b6 100644 --- a/hugolib/cascade_test.go +++ b/hugolib/cascade_test.go @@ -416,3 +416,66 @@ title: p1 (en) b.AssertFileContent("public/en/s1/p1/index.html", "|color: red (en)|size: medium|") // fails: file contains "|color: red (en)|size: |" b.AssertFileContent("public/de/s1/p1/index.html", "|color: red (de)|size: medium|") } + +// Issue 14409 +func TestCascadeDraftTrue14409(t *testing.T) { + t.Parallel() + + files := ` +-- hugo.toml -- +disableKinds = ['rss','taxonomy','term'] +defaultContentLanguage = 'en' +defaultContentLanguageInSubdir = true + +[languages.en] + weight = 1 +[languages.de] + weight = 2 + +[[cascade]] + draft = true + [cascade.target.sites.matrix] + languages = ['en'] +-- content/_index.en.md -- +--- +title: home en +draft: false +--- +-- content/_index.de.md -- +--- +title: home de +draft: false +--- +-- content/s1/_index.en.md -- +--- +title: s1 en +draft: false +--- +-- content/s1/_index.de.md -- +--- +title: s1 de +draft: false +--- +-- content/s1/p1.en.md -- +--- +title: p1 en +--- +-- content/s1/p1.de.md -- +--- +title: p1 de +--- +-- layouts/all.html -- +{{ .Title }} +` + + b := Test(t, files) + + b.AssertFileExists("public/de/index.html", true) + b.AssertFileExists("public/en/index.html", true) + + b.AssertFileExists("public/de/s1/index.html", true) + b.AssertFileExists("public/en/s1/index.html", true) + + b.AssertFileExists("public/de/s1/p1/index.html", true) + b.AssertFileExists("public/en/s1/p1/index.html", false) +} diff --git a/hugolib/content_map_page_assembler.go b/hugolib/content_map_page_assembler.go index e8c37084c..5a61795c7 100644 --- a/hugolib/content_map_page_assembler.go +++ b/hugolib/content_map_page_assembler.go @@ -86,7 +86,7 @@ func newAllPagesAssembler( seenTerms: hmaps.NewMap[term, sitesmatrix.Vectors](), droppedPages: hmaps.NewMap[*Site, []string](), seenRootSections: seenRootSections, - assembleSectionsInParallel: true, + assembleSectionsInParallel: !h.isRebuild(), // On partial rebuilds, there's potential data races with parallel section assembly. pwRoot: pw, rwRoot: rw, } @@ -273,27 +273,23 @@ func (a *allPagesAssembler) doCreatePages(prefix string, depth int) error { return false } - var drop bool if !site.shouldBuild(p) { + (&p.m.pageConfig.Build).Disable() switch p.Kind() { case kinds.KindHome, kinds.KindSection, kinds.KindTaxonomy: - // We need to keep these for the structure, but disable - // them so they don't get listed/rendered. - (&p.m.pageConfig.Build).Disable() + // We need to keep these for the structure. default: - // Skip this page. + // Drop this page. a.droppedPages.WithWriteLock( func(m map[*Site][]string) error { m[site] = append(m[site], s) return nil }, ) - - drop = true } } - if !drop && n == nil { + if n == nil { if n2 == nil { // Avoid creating a map for one node. n2 = p diff --git a/magefile.go b/magefile.go index e09e7987b..266e0bfd4 100644 --- a/magefile.go +++ b/magefile.go @@ -194,13 +194,13 @@ func TestRace() error { return err } for _, pkg := range pkgs { - slashCount := strings.Count(pkg, "/") + /*slashCount := strings.Count(pkg, "/") if slashCount > 1 { continue } if pkg != "." { pkg += "/..." - } + }*/ if err := cmp.Or(CleanTest(), UninstallAll()); err != nil { return err }