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
|
run: go install honnef.co/go/tools/cmd/staticcheck@latest
|
||||||
- if: matrix.os == 'ubuntu-latest'
|
- if: matrix.os == 'ubuntu-latest'
|
||||||
name: Run staticcheck
|
name: Run staticcheck
|
||||||
run: staticcheck ./...
|
run: |
|
||||||
|
export STATICCHECK_CACHE="${{ runner.temp }}/staticcheck"
|
||||||
|
staticcheck ./...
|
||||||
|
rm -rf ${{ runner.temp }}/staticcheck
|
||||||
- if: matrix.os != 'windows-latest'
|
- if: matrix.os != 'windows-latest'
|
||||||
name: Check
|
name: Check
|
||||||
run: |
|
run: |
|
||||||
@@ -118,16 +121,15 @@ jobs:
|
|||||||
# See issue #11052. We limit the build to regular test (no -race flag) on Windows for now.
|
# See issue #11052. We limit the build to regular test (no -race flag) on Windows for now.
|
||||||
name: Test
|
name: Test
|
||||||
run: |
|
run: |
|
||||||
mage -v test;
|
mage -v test
|
||||||
|
go clean -i -testcache
|
||||||
env:
|
env:
|
||||||
HUGO_BUILD_TAGS: extended,withdeploy
|
HUGO_BUILD_TAGS: extended,withdeploy
|
||||||
- name: Build tags
|
|
||||||
run: |
|
|
||||||
go install -tags extended
|
|
||||||
- if: matrix.os == 'ubuntu-latest'
|
- if: matrix.os == 'ubuntu-latest'
|
||||||
name: Build for dragonfly
|
name: Build for dragonfly
|
||||||
run: |
|
run: |
|
||||||
go install
|
go install
|
||||||
|
go clean -i -cache
|
||||||
env:
|
env:
|
||||||
GOARCH: amd64
|
GOARCH: amd64
|
||||||
GOOS: dragonfly
|
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/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|")
|
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](),
|
seenTerms: hmaps.NewMap[term, sitesmatrix.Vectors](),
|
||||||
droppedPages: hmaps.NewMap[*Site, []string](),
|
droppedPages: hmaps.NewMap[*Site, []string](),
|
||||||
seenRootSections: seenRootSections,
|
seenRootSections: seenRootSections,
|
||||||
assembleSectionsInParallel: true,
|
assembleSectionsInParallel: !h.isRebuild(), // On partial rebuilds, there's potential data races with parallel section assembly.
|
||||||
pwRoot: pw,
|
pwRoot: pw,
|
||||||
rwRoot: rw,
|
rwRoot: rw,
|
||||||
}
|
}
|
||||||
@@ -273,27 +273,23 @@ func (a *allPagesAssembler) doCreatePages(prefix string, depth int) error {
|
|||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
var drop bool
|
|
||||||
if !site.shouldBuild(p) {
|
if !site.shouldBuild(p) {
|
||||||
|
(&p.m.pageConfig.Build).Disable()
|
||||||
switch p.Kind() {
|
switch p.Kind() {
|
||||||
case kinds.KindHome, kinds.KindSection, kinds.KindTaxonomy:
|
case kinds.KindHome, kinds.KindSection, kinds.KindTaxonomy:
|
||||||
// We need to keep these for the structure, but disable
|
// We need to keep these for the structure.
|
||||||
// them so they don't get listed/rendered.
|
|
||||||
(&p.m.pageConfig.Build).Disable()
|
|
||||||
default:
|
default:
|
||||||
// Skip this page.
|
// Drop this page.
|
||||||
a.droppedPages.WithWriteLock(
|
a.droppedPages.WithWriteLock(
|
||||||
func(m map[*Site][]string) error {
|
func(m map[*Site][]string) error {
|
||||||
m[site] = append(m[site], s)
|
m[site] = append(m[site], s)
|
||||||
return nil
|
return nil
|
||||||
},
|
},
|
||||||
)
|
)
|
||||||
|
|
||||||
drop = true
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if !drop && n == nil {
|
if n == nil {
|
||||||
if n2 == nil {
|
if n2 == nil {
|
||||||
// Avoid creating a map for one node.
|
// Avoid creating a map for one node.
|
||||||
n2 = p
|
n2 = p
|
||||||
|
|||||||
+2
-2
@@ -194,13 +194,13 @@ func TestRace() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
for _, pkg := range pkgs {
|
for _, pkg := range pkgs {
|
||||||
slashCount := strings.Count(pkg, "/")
|
/*slashCount := strings.Count(pkg, "/")
|
||||||
if slashCount > 1 {
|
if slashCount > 1 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
if pkg != "." {
|
if pkg != "." {
|
||||||
pkg += "/..."
|
pkg += "/..."
|
||||||
}
|
}*/
|
||||||
if err := cmp.Or(CleanTest(), UninstallAll()); err != nil {
|
if err := cmp.Or(CleanTest(), UninstallAll()); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user