mirror of
https://github.com/gohugoio/hugo.git
synced 2026-08-24 15:28:54 +00:00
create: Fix non-deterministic conflict detection in hugo new content
The contentInclusionFilter used strings.Contains to match filenames against the target path. Because strings.Contains is a substring check, a directory entry like "content/about" matches "content/about.md", causing unrelated files to be pulled into the mini-build. Whether the conflict was then detected depended on whether the filesystem walker delivered a directory entry or a full file path. Also adds an upfront check for the directory-conflict case, since a corrected filter alone would allow about.md to be created alongside an existing about/ directory. Closes #12602 Closes #12786 Closes #14112 Closes #14769 Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
547ab29ced
commit
6436deb3e1
@@ -5,8 +5,8 @@ hugo new content --kind post post/first-post.md
|
||||
grep 'draft = true' content/post/first-post.md
|
||||
|
||||
# Issue 12599
|
||||
cd $WORK
|
||||
|
||||
cd $WORK
|
||||
hugo new project --format toml --force issue-12599
|
||||
cp hugo.toml issue-12599/hugo.toml
|
||||
cd issue-12599
|
||||
@@ -16,6 +16,33 @@ grep 'DATE _2099-12-31_' public/s1/p1/index.html
|
||||
grep 'SLUG _p1_' public/s1/p1/index.html
|
||||
grep 'TITLE _2099 12 31 P1_' public/s1/p1/index.html
|
||||
|
||||
# Issue 12602
|
||||
|
||||
cd $WORK
|
||||
hugo new project issue-12602
|
||||
cd issue-12602
|
||||
hugo new content about/_index.md
|
||||
! hugo new content about.md
|
||||
stderr 'the target path conflicts with existing content'
|
||||
|
||||
# Issue 12786
|
||||
|
||||
cd $WORK
|
||||
hugo new project issue-12786
|
||||
cd issue-12786
|
||||
hugo new content content/p1/index.md
|
||||
! hugo new content content/p1/p2.md
|
||||
stderr 'the target path conflicts with existing content'
|
||||
|
||||
# Issue 14112
|
||||
|
||||
cd $WORK
|
||||
hugo new project issue-14112
|
||||
cd issue-14112
|
||||
hugo new content P1.md
|
||||
! hugo new content p1.md
|
||||
stderr 'the target path conflicts with existing content'
|
||||
|
||||
-- hugo.toml --
|
||||
disableKinds = ['home','rss','section','sitemap','taxonomy','term']
|
||||
[frontmatter]
|
||||
|
||||
Reference in New Issue
Block a user