]> git.maquefel.me Git - brevno-suite/hugo/commitdiff
Fix cascade draft panic
authorBjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Fri, 23 Jan 2026 15:08:29 +0000 (16:08 +0100)
committerGitHub <noreply@github.com>
Fri, 23 Jan 2026 15:08:29 +0000 (16:08 +0100)
Fixes #14409
Fixes #14412

Co-authored-by: Joe Mooring <joe.mooring@veriphor.com>
.github/workflows/test.yml
hugolib/cascade_test.go
hugolib/content_map_page_assembler.go
magefile.go

index b8670cb4d19ed8cd1a9fedf2f6bc38da25ced0b3..91af1538eefd1fc64f804bc57dad717d52fe164f 100644 (file)
@@ -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
index 660093599354046ab6cbf658ead6fb3869f337ce..8eaa369b64d6bfcc97e75da9f2cb3112175629aa 100644 (file)
@@ -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)
+}
index e8c37084ce7b20c20b0091657e73d439fca8b79e..5a61795c7c274e100ad257cee97ee4bc1f8729ca 100644 (file)
@@ -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
index e09e7987b8fb330da22122432f33098dd381249b..266e0bfd4234b13de77db042c3af30a83c3f785a 100644 (file)
@@ -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
                        }