diff options
author | Bjørn Erik Pedersen <[email protected]> | 2024-12-15 10:52:53 +0100 |
---|---|---|
committer | Bjørn Erik Pedersen <[email protected]> | 2024-12-16 08:33:10 +0100 |
commit | 744b8566ec8ea138a63d3787dc2a0dd81511e492 (patch) | |
tree | 438e1c7127375eaaef3db610f318fd8b5dec803c | |
parent | 7de5317aef7866ed559f0dbcd2f3370944b30ed6 (diff) | |
download | hugo-744b8566ec8ea138a63d3787dc2a0dd81511e492.tar.gz hugo-744b8566ec8ea138a63d3787dc2a0dd81511e492.zip |
Fix a rebuild on resource rename case
-rw-r--r-- | hugolib/hugo_sites_build.go | 18 | ||||
-rw-r--r-- | internal/js/esbuild/batch_integration_test.go | 14 |
2 files changed, 28 insertions, 4 deletions
diff --git a/hugolib/hugo_sites_build.go b/hugolib/hugo_sites_build.go index 5346e2e6b..02ecd5785 100644 --- a/hugolib/hugo_sites_build.go +++ b/hugolib/hugo_sites_build.go @@ -738,15 +738,15 @@ type pathChange struct { // The path to the changed file. p *paths.Path - // If true, this is a delete operation (a delete or a rename). - delete bool + // If true, this is a structural change (e.g. a delete or a rename). + structural bool // If true, this is a directory. isDir bool } func (p pathChange) isStructuralChange() bool { - return p.delete || p.isDir + return p.structural || p.isDir } func (h *HugoSites) processPartialRebuildChanges(ctx context.Context, l logg.LevelLogger, config *BuildCfg) error { @@ -912,7 +912,7 @@ func (h *HugoSites) processPartialFileEvents(ctx context.Context, l logg.LevelLo } } - addedOrChangedContent = append(addedOrChangedContent, pathChange{p: pathInfo, delete: delete, isDir: isDir}) + addedOrChangedContent = append(addedOrChangedContent, pathChange{p: pathInfo, structural: delete, isDir: isDir}) case files.ComponentFolderLayouts: tmplChanged = true @@ -1033,6 +1033,16 @@ func (h *HugoSites) processPartialFileEvents(ctx context.Context, l logg.LevelLo handleChange(id, false, true) } + for _, id := range changes { + if id == identity.GenghisKhan { + for i, cp := range addedOrChangedContent { + cp.structural = true + addedOrChangedContent[i] = cp + } + break + } + } + resourceFiles := h.fileEventsContentPaths(addedOrChangedContent) changed := &WhatChanged{ diff --git a/internal/js/esbuild/batch_integration_test.go b/internal/js/esbuild/batch_integration_test.go index 07f99ee4e..3501f820a 100644 --- a/internal/js/esbuild/batch_integration_test.go +++ b/internal/js/esbuild/batch_integration_test.go @@ -184,6 +184,20 @@ func TestBatchEditScriptParam(t *testing.T) { b.AssertFileContent("public/mybatch/mygroup.js", "param-p1-main-edited") } +func TestBatchRenameBundledScript(t *testing.T) { + files := jsBatchFilesTemplate + b := hugolib.TestRunning(t, files, hugolib.TestOptWithOSFs()) + b.AssertFileContent("public/mybatch/p1.js", "P1 Script") + b.RenameFile("content/p1/p1script.js", "content/p1/p1script2.js") + _, err := b.BuildE() + b.Assert(err, qt.IsNotNil) + b.Assert(err.Error(), qt.Contains, "resource not set") + + // Rename it back. + b.RenameFile("content/p1/p1script2.js", "content/p1/p1script.js") + b.Build() +} + func TestBatchErrorScriptResourceNotSet(t *testing.T) { files := strings.Replace(jsBatchFilesTemplate, `(resources.Get "js/main.js")`, `(resources.Get "js/doesnotexist.js")`, 1) b, err := hugolib.TestE(t, files, hugolib.TestOptWithOSFs()) |