Fix rebuild when changing mixed case named templates - hugo - [fork] hugo port for 9front
HTML git clone git@git.drkhsh.at/hugo.git
DIR Log
DIR Files
DIR Refs
DIR Submodules
DIR README
DIR LICENSE
---
DIR commit 19937a20adcce473300445a0013c99c0d1f6d916
DIR parent c1ea22a232add4c6f371b4278dd3089f102ac15c
HTML Author: Bjørn Erik Pedersen <bjorn.erik.pedersen@gmail.com>
Date: Wed, 20 Mar 2024 11:00:08 +0100
Fix rebuild when changing mixed case named templates
Fixes #12165
Diffstat:
M hugolib/hugo_sites_build.go | 2 +-
M hugolib/rebuild_test.go | 24 ++++++++++++++++++++++++
2 files changed, 25 insertions(+), 1 deletion(-)
---
DIR diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go
@@ -730,7 +730,7 @@ func (h *HugoSites) processPartial(ctx context.Context, l logg.LevelLogger, conf
case files.ComponentFolderLayouts:
tmplChanged = true
- templatePath := pathInfo.TrimLeadingSlash().PathNoLang()
+ templatePath := pathInfo.Unnormalized().TrimLeadingSlash().PathNoLang()
if !h.Tmpl().HasTemplate(templatePath) {
tmplAdded = true
}
DIR diff --git a/hugolib/rebuild_test.go b/hugolib/rebuild_test.go
@@ -1490,3 +1490,27 @@ title: "Default"
// Just make sure that it doesn't panic.
b.EditFileReplaceAll("archetypes/default.md", "Default", "Default Edited").Build()
}
+
+func TestRebuildEditMixedCaseTemplateFileIssue12165(t *testing.T) {
+ t.Parallel()
+
+ files := `
+-- hugo.toml --
+baseURL = "https://example.com"
+disableLiveReload = true
+-- layouts/partials/MyTemplate.html --
+MyTemplate
+-- layouts/index.html --
+MyTemplate: {{ partial "MyTemplate.html" . }}|
+
+
+`
+
+ b := TestRunning(t, files)
+
+ b.AssertFileContent("public/index.html", "MyTemplate: MyTemplate")
+
+ b.EditFileReplaceAll("layouts/partials/MyTemplate.html", "MyTemplate", "MyTemplate Edited").Build()
+
+ b.AssertFileContent("public/index.html", "MyTemplate: MyTemplate Edited")
+}