mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
Fix cascade draft panic
Fixes #14409 Fixes #14412 Co-authored-by: Joe Mooring <joe.mooring@veriphor.com>
This commit is contained in:
committed by
GitHub
parent
192e3c453e
commit
11f7f39913
@@ -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
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
+2
-2
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user