Backtestshugorun-20261009-153657#15266
Consider bumping mainImageVersionNumber
Our patch was judged better than the merged fix.
In this judgment, Patch B = our agent, Patch A = the merged fix.
The issue asks for a bump to mainImageVersionNumber so that cached images built with the old buggy code are invalidated. Patch B does exactly that: it sets mainImageVersionNumber to 2. It also fixes a real gap at the root. `Filter` overwrote `confMain.Key` with a hash of only the filters, which dropped the version suffixes appended by DecodeImageConfig. B now hashes `confMain.Key` together with the filters, so any version bump also invalidates filtered images. That matters because the fixes in question (filters on transparent colors, geometric filter chains) live largely in the filter path. B adds a meaningful test, TestMainImageVersionNumberInvalidatesCache. It builds a site, changes the version number through a test-only export hook, rebuilds, and asserts that every link changes, including Filter outputs. This test would fail before the Filter key change. B also regenerates the expected hashes and golden files consistently. Patch A does not bump the main version number. It adds a PNG entry to the format version map, which leaves non-PNG outputs stale (e.g. paletted GIFs and transparent-color filters targeting other formats). It also exports the global variables `MainImageVersionNumber` and `FormatVersionNumbers` as mutable package state just so `image.go` can reach them. This duplicates logic already in DecodeImageConfig rather than reusing `confMain.Key`, and it widens the API. A adds no test proving invalidation, only hash updates. It also carries unrelated formatting churn (reflowed AssertFileContent calls) in several test files. B is more correct, better tested and cleaner.
The judge saw only the two patches, labelled A and B in random order, with issue links and version numbers removed. The reasoning above is shown verbatim.
Solve
1h 3m
Wall-clock time in the container
Full test suite
No new failures
2,325 passed · 96 skipped · 2,421 total
Contamination audit
Clean
No sign the agent saw the real fix
Patch size
169vs 102 merged
Changed lines, ours vs merged
The issue
View on GitHubUnless site owners flush their image cache, they will not see the result of these fixes:
9e7c978e6 resources/images: Preserve the source palette for geometric filter chains
77856683d resources/images: Fix filters on transparent colors and paletted images
Argument against doing this: I suspect very few sites are affected by the underlying issues.
I don't have a strong opinion either way.
The two patches
hugolib/hugo_sites_multihost_test.goindex 3ecfa7e9d..426c76fb9 100644@@ -207,9 +207,9 @@ title: mybundle-en b.AssertFileExists("public/de/mybundle/pixel.png", true) b.AssertFileExists("public/en/mybundle/pixel.png", true) - b.AssertFileExists("public/de/mybundle/pixel_hu_c8522c65d73a0421.png", true)+ b.AssertFileExists("public/de/mybundle/pixel_hu_410c334bfbcb9912.png", true) // failing test below- b.AssertFileExists("public/en/mybundle/pixel_hu_c8522c65d73a0421.png", true)+ b.AssertFileExists("public/en/mybundle/pixel_hu_410c334bfbcb9912.png", true) } func TestMultihostResourceOneBaseURLWithSubPath(t *testing.T) {hugolib/pagesfromdata/pagesfromgotmpl_integration_test.goindex 4ed81c480..e7dfaad03 100644@@ -125,7 +125,7 @@ docs/p1/sub/mymixcasetext2.txt "RelPermalink: /docs/p1/sub/mymixcasetext2.txt|Name: sub/mymixcasetext2.txt|", "RelPermalink: /mydata.yaml|Name: sub/data1.yaml|Title: Sub data|Params: map[]|", "Featured Image: /a/pixel.png|featured.png|",- "Resized Featured Image: /a/pixel_hu_a354833fd576551d.png|10|",+ "Resized Featured Image: /a/pixel_hu_bedb7691603c6b4d.png|10|", // Resource from string "RelPermalink: /docs/p1/mytext.txt|Name: textresource|Title: My Text Resource|Params: map[param1:param1v]|", // Datesinternal/warpc/avif_integration_test.goindex 9b3b68cb3..c44be07b7 100644@@ -83,9 +83,9 @@ text:{{ ($img.Process "avif text").RelPermalink }}| b := hugolib.Test(t, files) b.AssertFileContent("public/index.html", `-default:/logo_hu_72e150ce03376cfd.avif|-photo:/logo_hu_72e150ce03376cfd.avif|-text:/logo_hu_9de8f282912bc925.avif|+default:/logo_hu_72be6fac035caee7.avif|+photo:/logo_hu_72be6fac035caee7.avif|+text:/logo_hu_89614023638100ee.avif| `) } internal/warpc/webp_integration_test.goindex 857b1c3e8..cdd459372 100644@@ -38,12 +38,12 @@ ImageConfig: {{ printf "%d/%d" $ic.Width $ic.Height }}| b := hugolib.Test(t, files) - b.ImageHelper("public/sunrise_hu_8dd1706a77fb35ce.webp").AssertFormat("webp").AssertIsAnimated(false)+ b.ImageHelper("public/sunrise_hu_3f86f07afd33f0cf.webp").AssertFormat("webp").AssertIsAnimated(false) b.AssertFileContent("public/index.html", "Original Width/Height: 1024/640|", "Resized Width:/Height 123/456|",- "Resized RelPermalink: /sunrise_hu_8dd1706a77fb35ce.webp|",+ "Resized RelPermalink: /sunrise_hu_3f86f07afd33f0cf.webp|", "ImageConfig: 1024/640|", ) }@@ -60,7 +60,7 @@ Resized RelPermalink: {{ $resized.RelPermalink }}| b := hugolib.Test(t, files) - b.ImageHelper("public/gopher_hu_cc98ebaf742cba8e.webp").AssertFormat("webp")+ b.ImageHelper("public/gopher_hu_ea288bd5129549a4.webp").AssertFormat("webp") } func TestWebPInvalid(t *testing.T) {@@ -112,13 +112,13 @@ sourcefilename: ../../resources/testdata/giphy.gif // Frame durations in ms. giphyFrameDurations := []int{200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200, 200} - b.ImageHelper("public/giphy_hu_bb052284cc220165.webp").AssertFormat("webp").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(giphyFrameDurations)- b.ImageHelper("public/giphy_hu_c6b8060edf0363b1.gif").AssertFormat("gif").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(giphyFrameDurations)+ b.ImageHelper("public/giphy_hu_be95bbbae6a8625a.webp").AssertFormat("webp").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(giphyFrameDurations)+ b.ImageHelper("public/giphy_hu_5bb5701e38a6a79d.gif").AssertFormat("gif").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(giphyFrameDurations) // Source animated webp: animFrameDurations := []int{80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80, 80}- b.ImageHelper("public/anim_hu_edc2f24aaad2cee6.webp").AssertFormat("webp").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(animFrameDurations)- b.ImageHelper("public/anim_hu_58eb49733894e7ce.gif").AssertFormat("gif").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(animFrameDurations)+ b.ImageHelper("public/anim_hu_8a37856866ce0ae5.webp").AssertFormat("webp").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(animFrameDurations)+ b.ImageHelper("public/anim_hu_7bee881b316e610f.gif").AssertFormat("gif").AssertIsAnimated(true).AssertLoopCount(0).AssertFrameDurations(animFrameDurations) } // See issue 14985.resources/image.goindex 10df3edda..cb7c83a53 100644@@ -322,7 +322,9 @@ func (i *imageResource) Filter(filters ...any) (images.ImageResource, error) { } confMain.Action = images.ActionFilter- confMain.Key = hashing.HashString(gfilters)+ // Keep the version numbers etc. from DecodeImageConfig in the key,+ // so bumping them also invalidates filtered images.+ confMain.Key = hashing.HashString(confMain.Key, gfilters) // Geometric filters cannot introduce colors outside the source palette. for _, f := range gfilters {resources/image_test.goindex befb18cf2..0a3f8101a 100644@@ -113,28 +113,28 @@ func TestImageTransformBasic(t *testing.T) { assertWidthHeight(resizedAndRotated, 125, 200) assertWidthHeight(resized, 300, 200)- c.Assert(resized.RelPermalink(), qt.Equals, "/a/sunset_hu_f4f15cdbaaca3b2d.jpg")+ c.Assert(resized.RelPermalink(), qt.Equals, "/a/sunset_hu_4253e92565fd4762.jpg") fitted, err := resized.Fit("50x50") c.Assert(err, qt.IsNil)- c.Assert(fitted.RelPermalink(), qt.Equals, "/a/sunset_hu_c9781e950a09210.jpg")+ c.Assert(fitted.RelPermalink(), qt.Equals, "/a/sunset_hu_4178c144aac13fa5.jpg") assertWidthHeight(fitted, 50, 33) // Check the MD5 key threshold fittedAgain, _ := fitted.Fit("10x20") fittedAgain, err = fittedAgain.Fit("10x20") c.Assert(err, qt.IsNil)- c.Assert(fittedAgain.RelPermalink(), qt.Equals, "/a/sunset_hu_78c1665fdce5ec4d.jpg")+ c.Assert(fittedAgain.RelPermalink(), qt.Equals, "/a/sunset_hu_2f7976e6f4b458be.jpg") assertWidthHeight(fittedAgain, 10, 7) filled, err := image.Fill("200x100 bottomLeft") c.Assert(err, qt.IsNil)- c.Assert(filled.RelPermalink(), qt.Equals, "/a/sunset_hu_b3e01daae854e587.jpg")+ c.Assert(filled.RelPermalink(), qt.Equals, "/a/sunset_hu_53f1b268f6e519dc.jpg") assertWidthHeight(filled, 200, 100) smart, err := image.Fill("200x100 smart") c.Assert(err, qt.IsNil)- c.Assert(smart.RelPermalink(), qt.Equals, "/a/sunset_hu_e548e0b0d6759ee7.jpg")+ c.Assert(smart.RelPermalink(), qt.Equals, "/a/sunset_hu_596ff1c1e90bc8d5.jpg") assertWidthHeight(smart, 200, 100) // Check cache@@ -144,12 +144,12 @@ func TestImageTransformBasic(t *testing.T) { cropped, err := image.Crop("300x300 topRight") c.Assert(err, qt.IsNil)- c.Assert(cropped.RelPermalink(), qt.Equals, "/a/sunset_hu_9016246670a22728.jpg")+ c.Assert(cropped.RelPermalink(), qt.Equals, "/a/sunset_hu_ad8e3cbd7c52e97.jpg") assertWidthHeight(cropped, 300, 300) smartcropped, err := image.Crop("200x200 smart") c.Assert(err, qt.IsNil)- c.Assert(smartcropped.RelPermalink(), qt.Equals, "/a/sunset_hu_2ffd7547f08a145d.jpg")+ c.Assert(smartcropped.RelPermalink(), qt.Equals, "/a/sunset_hu_c9028e212e68d1.jpg") assertWidthHeight(smartcropped, 200, 200) // Check cache@@ -216,7 +216,7 @@ func TestImageTransformFormat(t *testing.T) { imagePng, err := image.Resize("450x png") c.Assert(err, qt.IsNil)- c.Assert(imagePng.RelPermalink(), qt.Equals, "/a/sunset_hu_63ccccb11ff4e285.png")+ c.Assert(imagePng.RelPermalink(), qt.Equals, "/a/sunset_hu_c0c4b885f5542da.png") c.Assert(imagePng.ResourceType(), qt.Equals, "image") assertExtWidthHeight(imagePng, ".png", 450, 281) c.Assert(imagePng.Name(), qt.Equals, "sunset.jpg")@@ -224,7 +224,7 @@ func TestImageTransformFormat(t *testing.T) { imageGif, err := image.Resize("225x gif") c.Assert(err, qt.IsNil)- c.Assert(imageGif.RelPermalink(), qt.Equals, "/a/sunset_hu_6d1f23c09eddc748.gif")+ c.Assert(imageGif.RelPermalink(), qt.Equals, "/a/sunset_hu_599159c94ec6d6df.gif") c.Assert(imageGif.ResourceType(), qt.Equals, "image") assertExtWidthHeight(imageGif, ".gif", 225, 141) c.Assert(imageGif.Name(), qt.Equals, "sunset.jpg")@@ -247,7 +247,7 @@ func TestImagePermalinkPublishOrder(t *testing.T) { }() check1 := func(img images.ImageResource) {- resizedLink := "/a/sunset_hu_3a097ae28aebc166.jpg"+ resizedLink := "/a/sunset_hu_dc0c41268a95f5d6.jpg" c.Assert(img.RelPermalink(), qt.Equals, resizedLink) assertImageFile(c, spec.PublishFs, resizedLink, 100, 50) }@@ -288,12 +288,12 @@ func TestImageBugs(t *testing.T) { c.Assert(err, qt.IsNil) c.Assert(resized, qt.Not(qt.IsNil)) c.Assert(resized.Width(), qt.Equals, 200)- c.Assert(resized.RelPermalink(), qt.Equals, "/a/1234567890qwertyuiopasdfghjklzxcvbnm5to6eeeeee7via8eleph_hu_a6f31c42e1afef07.jpg")+ c.Assert(resized.RelPermalink(), qt.Equals, "/a/1234567890qwertyuiopasdfghjklzxcvbnm5to6eeeeee7via8eleph_hu_b6262524cc48e393.jpg") resized, err = resized.Resize("100x") c.Assert(err, qt.IsNil) c.Assert(resized, qt.Not(qt.IsNil)) c.Assert(resized.Width(), qt.Equals, 100)- c.Assert(resized.RelPermalink(), qt.Equals, "/a/1234567890qwertyuiopasdfghjklzxcvbnm5to6eeeeee7via8eleph_hu_14e106419fe28039.jpg")+ c.Assert(resized.RelPermalink(), qt.Equals, "/a/1234567890qwertyuiopasdfghjklzxcvbnm5to6eeeeee7via8eleph_hu_c3bdac81d3d4d418.jpg") }) // Issue #6137@@ -391,7 +391,7 @@ func TestImageResize8BitPNG(t *testing.T) { resized, err := image.Resize("800x") c.Assert(err, qt.IsNil) c.Assert(resized.MediaType().Type, qt.Equals, "image/png")- c.Assert(resized.RelPermalink(), qt.Equals, "/a/gohugoio_hu_626cfc4db4222bfe.png")+ c.Assert(resized.RelPermalink(), qt.Equals, "/a/gohugoio_hu_f3671d30e944b55d.png") c.Assert(resized.Width(), qt.Equals, 800) } resources/images/config.goindex f7d5fc727..c1812577c 100644@@ -84,7 +84,7 @@ var ( // Increment to mark all processed images as stale. Only use when absolutely needed. // See the finer grained smartCropVersionNumber.- mainImageVersionNumber = 1+ mainImageVersionNumber = 2 // Increment a format's version number to mark all processed images targeting // that format as stale, e.g. after a change to its encoder. This is finerresources/images/export_test.gonew file mode 100644index 000000000..0310e1700@@ -0,0 +1,22 @@+// Copyright 2026 The Hugo Authors. All rights reserved.+//+// Licensed under the Apache License, Version 2.0 (the "License");+// you may not use this file except in compliance with the License.+// You may obtain a copy of the License at+// http://www.apache.org/licenses/LICENSE-2.0+//+// Unless required by applicable law or agreed to in writing, software+// distributed under the License is distributed on an "AS IS" BASIS,+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.+// See the License for the specific language governing permissions and+// limitations under the License.++package images++// SetMainImageVersionNumber sets mainImageVersionNumber and returns a func+// that restores the previous value. Not safe for use in parallel tests.+func SetMainImageVersionNumber(v int) (restore func()) {+ orig := mainImageVersionNumber+ mainImageVersionNumber = v+ return func() { mainImageVersionNumber = orig }+}resources/images/images_integration_test.goindex 172449d21..baa0c9438 100644@@ -14,11 +14,14 @@ package images_test import (+ "strings" "testing" "github.com/bep/logg"+ qt "github.com/frankban/quicktest" "github.com/gohugoio/hugo/htesting" "github.com/gohugoio/hugo/hugolib"+ "github.com/gohugoio/hugo/resources/images" ) func TestAutoOrient(t *testing.T) {@@ -182,3 +185,51 @@ Page. builder.Build() } }++// Bumping mainImageVersionNumber must invalidate all processed images,+// including those created with Filter, so that site owners with a+// persisted image cache pick up fixes to the image processing.+// Note that this test is not parallel, as it modifies a global variable.+func TestMainImageVersionNumberInvalidatesCache(t *testing.T) {+ files := `+-- hugo.toml --+-- assets/sunset.jpg --+sourcefilename: ../testdata/sunset.jpg+-- assets/gopher.png --+sourcefilename: ../testdata/gopher-hero8.png+-- layouts/home.html --+{{ $img := resources.Get "sunset.jpg" }}+{{ $png := resources.Get "gopher.png" }}+Resize: {{ ($img.Resize "100x").RelPermalink }}|+Fill: {{ ($img.Fill "100x100 smart").RelPermalink }}|+Brightness: {{ ($img.Filter (images.Brightness 30)).RelPermalink }}|+Padding: {{ ($png.Filter (images.Padding 10 "#00000000")).RelPermalink }}|+ProcessFilter: {{ ($png.Filter (images.Process "resize 50x") images.AutoOrient).RelPermalink }}|+`+ tempDir := t.TempDir()++ build := func() map[string]string {+ b := hugolib.Test(t, files, hugolib.TestOptWithConfig(func(cfg *hugolib.IntegrationTestConfig) {+ cfg.NeedsOsFS = true+ cfg.WorkingDir = tempDir+ }))+ links := make(map[string]string)+ for line := range strings.SplitSeq(b.FileContent("public/index.html"), "\n") {+ k, v, found := strings.Cut(strings.TrimSpace(line), ": ")+ if found {+ links[k] = v+ }+ }+ b.Assert(links, qt.HasLen, 5)+ return links+ }++ before := build()+ restore := images.SetMainImageVersionNumber(1000)+ defer restore()+ after := build()++ for k, v := range before {+ qt.Assert(t, after[k], qt.Not(qt.Equals), v, qt.Commentf("%s: %s", k, v))+ }+}resources/images/imagetesting/testing.goindex 29c4ef4c4..a22b6b019 100644@@ -122,7 +122,7 @@ func RunGolden(opts GoldenImageTestOpts) *hugolib.IntegrationTestBuilder { shouldSkip := func(d fs.DirEntry) bool { if runtime.GOARCH == "arm64" { // TODO(bep) figure out why this fails on arm64. I have inspected the images, and they look identical.- if d.Name() == "giphy_hu_bb052284cc220165.webp" {+ if d.Name() == "giphy_hu_be95bbbae6a8625a.webp" { c.Logf("skipping %s on %s", d.Name(), runtime.GOARCH) return true }resources/images/testdata/images_golden/webp/animation/anim_hu_7bee881b316e610f.gifnew file mode 100644index 000000000..eeabfc836Binary files /dev/null and b/resources/images/testdata/images_golden/webp/animation/anim_hu_7bee881b316e610f.gif differresources/images/testdata/images_golden/webp/animation/anim_hu_8a37856866ce0ae5.webpnew file mode 100644index 000000000..ac9052d4aBinary files /dev/null and b/resources/images/testdata/images_golden/webp/animation/anim_hu_8a37856866ce0ae5.webp differresources/images/testdata/images_golden/webp/animation/giphy_hu_5bb5701e38a6a79d.gifnew file mode 100644index 000000000..66a6b73deBinary files /dev/null and b/resources/images/testdata/images_golden/webp/animation/giphy_hu_5bb5701e38a6a79d.gif differresources/images/testdata/images_golden/webp/animation/giphy_hu_be95bbbae6a8625a.webpnew file mode 100644index 000000000..5b6e9453dBinary files /dev/null and b/resources/images/testdata/images_golden/webp/animation/giphy_hu_be95bbbae6a8625a.webp differresources/resources_integration_test.goindex 71216e304..53b2dd1c0 100644@@ -56,9 +56,9 @@ anigif: {{ $anigif.RelPermalink }}|{{ $anigif.Width }}|{{ $anigif.Height }}|{{ $ assertImages := func() { b.AssertFileContent("public/index.html", `-gif: /mybundle/pixel_hu_d6bad5e71f783c98.gif|}|1|2|image/gif|-bmp: /mybundle/pixel_hu_a8812c9bf8812b53.bmp|}|2|3|image/bmp|-anigif: /mybundle/giphy_hu_7f64f85f904209d4.gif|4|5|image/gif|+gif: /mybundle/pixel_hu_a1e8150a56cb86d6.gif|}|1|2|image/gif|+bmp: /mybundle/pixel_hu_bd3c9bd9bbbdf258.bmp|}|2|3|image/bmp|+anigif: /mybundle/giphy_hu_1d76e84bfc3d8be8.gif|4|5|image/gif| `) } @@ -143,9 +143,9 @@ resize 2|RelPermalink: {{ $image.RelPermalink }}|MediaType: {{ $image.MediaType b := hugolib.Test(t, files) b.AssertFileContent("public/index.html",- "jpg|RelPermalink: /images/pixel_hu_38c3f257174fc757.jpg|MediaType: image/jpeg|Width: 1|Height: 1|",- "resize 1|RelPermalink: /images/pixel_hu_b5c2a3d88991f65a.jpg|MediaType: image/jpeg|Width: 20|Height: 30|",- "resize 2|RelPermalink: /images/pixel_hu_b5c2a3d88991f65a.jpg|MediaType: image/jpeg|Width: 20|Height: 30|",+ "jpg|RelPermalink: /images/pixel_hu_e08de20d757faa36.jpg|MediaType: image/jpeg|Width: 1|Height: 1|",+ "resize 1|RelPermalink: /images/pixel_hu_b35f5fdd723ec641.jpg|MediaType: image/jpeg|Width: 20|Height: 30|",+ "resize 2|RelPermalink: /images/pixel_hu_b35f5fdd723ec641.jpg|MediaType: image/jpeg|Width: 20|Height: 30|", ) } resources/transform_test.goindex feae43e41..d1dce2118 100644@@ -386,15 +386,15 @@ func TestTransform(t *testing.T) { resizedPublished1, err := img.Resize("40x40") c.Assert(err, qt.IsNil) c.Assert(resizedPublished1.Height(), qt.Equals, 40)- c.Assert(resizedPublished1.RelPermalink(), qt.Equals, "/gopher.changed_hu_6347c67500afc377.png")- assertShouldExist(c, spec, "public/gopher.changed_hu_6347c67500afc377.png", true)+ c.Assert(resizedPublished1.RelPermalink(), qt.Equals, "/gopher.changed_hu_46ada7dd67960f21.png")+ assertShouldExist(c, spec, "public/gopher.changed_hu_46ada7dd67960f21.png", true) // Permalink called. resizedPublished2, err := img.Resize("30x30") c.Assert(err, qt.IsNil) c.Assert(resizedPublished2.Height(), qt.Equals, 30)- c.Assert(resizedPublished2.Permalink(), qt.Equals, "https://example.com/gopher.changed_hu_2d293650135f63d6.png")- assertShouldExist(c, spec, "public/gopher.changed_hu_2d293650135f63d6.png", true)+ c.Assert(resizedPublished2.Permalink(), qt.Equals, "https://example.com/gopher.changed_hu_5fcc3eee2f2f036b.png")+ assertShouldExist(c, spec, "public/gopher.changed_hu_5fcc3eee2f2f036b.png", true) assertNoDuplicateWrites(c, spec) })testscripts/commands/hugo_gc_mixed_case_cache_dir.txtindex 7c7af1373..68f4d219b 100644@@ -11,7 +11,7 @@ hugo stdout 'Processed images │ 1 ' tree resources/_gen-stdout 'pix_hu_a354833fd576551d.png'+stdout 'pix_hu_bedb7691603c6b4d.png' # Simulate a cache created by an older Hugo version. mv resources/_gen/images/mybundle resources/_gen/images/MyBundle@@ -20,7 +20,7 @@ hugo --gc stdout 'Cleaned │ 0 ' tree resources/_gen-stdout 'pix_hu_a354833fd576551d.png'+stdout 'pix_hu_bedb7691603c6b4d.png' -- hugo.toml -- disableKinds = ["term", "taxonomy", "home"]tpl/images/images_integration_test.goindex 55b541ff1..9afe96a20 100644@@ -161,8 +161,8 @@ Brightnes func: {{ ($img | images.Filter (images.Brightness 12) ).RelPermalink } b.AssertFileContent("public/index.html", ` images.Config: 222 Resize to 100x100: 100-Brightnes method: /qr_hu_d5f06fd7594d0594.png-Brightnes func: /qr_hu_d5f06fd7594d0594.png+Brightnes method: /qr_hu_a3a1e69a29146a.png+Brightnes func: /qr_hu_a3a1e69a29146a.png `) } @@ -184,8 +184,8 @@ Brightnes func: {{ ($img | images.Filter (images.Brightness 12) ).RelPermalink } b.AssertFileContent("public/index.html", ` images.Config: 222 Resize to 100x100: 100-Brightnes method: /qr_hu_d5f06fd7594d0594.webp-Brightnes func: /qr_hu_d5f06fd7594d0594.webp+Brightnes method: /qr_hu_a3a1e69a29146a.webp+Brightnes func: /qr_hu_a3a1e69a29146a.webp `) } @@ -214,7 +214,7 @@ Image: {{ $img.RelPermalink }} cfg.NeedsOsFS = true cfg.WorkingDir = tempDir }))- b.AssertFileContent("public/index.html", `Image: /qr_hu_6b5f59be9c4d3b3a.webp`)+ b.AssertFileContent("public/index.html", `Image: /qr_hu_46a51a85c8fb8c14.webp`) } }tpl/resources/resources_integration_test.goindex b5c611d52..43e3292ab 100644@@ -60,7 +60,7 @@ Copy3: {{ $copy3.RelPermalink}}|{{ $copy3.MediaType }}|{{ $copy3.Content | safeJ b.AssertFileContent("public/index.html", ` Image Orig: /blog/images/pixel.png|image/png|1|1|-Image Copy1: /blog/images/copy_hu_ef85c36d9b9eff0.png|image/png|3|4|+Image Copy1: /blog/images/copy_hu_10bd41e3dfc8ade0.png|image/png|3|4| Image Copy2: /blog/images/copy2.png|image/png|3|4| Image Copy3: image/png|3|4| Orig: /blog/js/foo.js|text/javascript|let foo;|
hugolib/hugo_sites_multihost_test.goindex 3ecfa7e9d..5769fc64e 100644@@ -154,11 +154,13 @@ title: "Mybundle fr" ` b := Test(t, files) - b.AssertFileContent("public/fr/section/mybundle/index.html",+ b.AssertFileContent(+ "public/fr/section/mybundle/index.html", "fr: .body{color:french}|/section/mybundle/styles.min.css|", ) - b.AssertFileContent("public/en/section/mybundle/index.html",+ b.AssertFileContent(+ "public/en/section/mybundle/index.html", "en: .body{color:english}|/section/mybundle/styles.min.css|", ) @@ -207,9 +209,9 @@ title: mybundle-en b.AssertFileExists("public/de/mybundle/pixel.png", true) b.AssertFileExists("public/en/mybundle/pixel.png", true) - b.AssertFileExists("public/de/mybundle/pixel_hu_c8522c65d73a0421.png", true)+ b.AssertFileExists("public/de/mybundle/pixel_hu_a25c5b589ae00856.png", true) // failing test below- b.AssertFileExists("public/en/mybundle/pixel_hu_c8522c65d73a0421.png", true)+ b.AssertFileExists("public/en/mybundle/pixel_hu_a25c5b589ae00856.png", true) } func TestMultihostResourceOneBaseURLWithSubPath(t *testing.T) {hugolib/pagesfromdata/pagesfromgotmpl_integration_test.goindex 4ed81c480..ee3569f29 100644@@ -112,7 +112,8 @@ docs/p1/sub/mymixcasetext2.txt // Page from markdown file. b.AssertFileContent("public/docs/pfile/index.html", "Dates: Date: 2023-03-01|Lastmod: 2023-03-01|PublishDate: 2023-03-01|ExpiryDate: 0001-01-01|") // Pages from gotmpl.- b.AssertFileContent("public/docs/p1/index.html",+ b.AssertFileContent(+ "public/docs/p1/index.html", "Single: p1:p1|", "Path: /docs/p1|", "<strong>Hello World</strong>",@@ -125,7 +126,7 @@ docs/p1/sub/mymixcasetext2.txt "RelPermalink: /docs/p1/sub/mymixcasetext2.txt|Name: sub/mymixcasetext2.txt|", "RelPermalink: /mydata.yaml|Name: sub/data1.yaml|Title: Sub data|Params: map[]|", "Featured Image: /a/pixel.png|featured.png|",- "Resized Featured Image: /a/pixel_hu_a354833fd576551d.png|10|",+ "Resized Featured Image: /a/pixel_hu_51638841a22bb583.png|10|", // Resource from string "RelPermalink: /docs/p1/mytext.txt|Name: textresource|Title: My Text Resource|Params: map[param1:param1v]|", // Dates@@ -174,25 +175,29 @@ allow = [%s] b := hugolib.Test(t, files) if supportsAsciiDoc {- b.AssertFileContent("public/docs/asciidoc/index.html",+ b.AssertFileContent(+ "public/docs/asciidoc/index.html", "Mark my words, <mark>automation is essential</mark>", "Path: /docs/asciidoc|", ) } if supportsPandoc {- b.AssertFileContent("public/docs/pandoc/index.html",+ b.AssertFileContent(+ "public/docs/pandoc/index.html", "This <del>is deleted text.</del>", "Path: /docs/pandoc|", ) } if supportsRst {- b.AssertFileContent("public/docs/rst/index.html",+ b.AssertFileContent(+ "public/docs/rst/index.html", "This is <em>bold</em>", "Path: /docs/rst|", ) } - b.AssertFileContent("public/docs/org/index.html",+ b.AssertFileContent(+ "public/docs/org/index.html", "the ability to use <del>strikethrough</del> is a plus", "Path: /docs/org|", )@@ -305,14 +310,16 @@ func TestPagesFromGoTmplMovePage(t *testing.T) { func TestPagesFromGoTmplRemoveGoTmpl(t *testing.T) { t.Parallel() b := hugolib.TestRunning(t, filesPagesFromDataTempleBasic)- b.AssertFileContent("public/index.html",+ b.AssertFileContent(+ "public/index.html", "RegularPagesRecursive: p1:p1:/docs/p1|p2title:/docs/p2|p3title:/docs/p3|p4title:/docs/p4|pfile:/docs/pfile|$", "Sections: Docs:/docs|", ) b.AssertFileContent("public/docs/index.html", "RegularPagesRecursive: p1:p1:/docs/p1|p2title:/docs/p2|p3title:/docs/p3|p4title:/docs/p4|pfile:/docs/pfile|$") b.RemoveFiles("content/docs/_content.gotmpl").Build() // One regular page left.- b.AssertFileContent("public/index.html",+ b.AssertFileContent(+ "public/index.html", "RegularPagesRecursive: pfile:/docs/pfile|$", "Sections: Docs:/docs|", )@@ -596,7 +603,8 @@ disableKinds = ['home','section','rss','sitemap','taxonomy','term'] b := hugolib.Test(t, files) - b.AssertFileContent("public/p1/index.html",+ b.AssertFileContent(+ "public/p1/index.html", "p1|param1v", "data1.yaml|param1v", )@@ -651,7 +659,8 @@ Footer: {{ range index site.Menus.footer }}{{ .Name }}|{{ end }}| ` b := hugolib.Test(t, files) - b.AssertFileContent("public/index.html",+ b.AssertFileContent(+ "public/index.html", "Main: Main|p1|p2||", "Footer: Footer|p2||", )@@ -706,7 +715,8 @@ summary: {{ .Summary }}|content: {{ .Content}} b := hugolib.Test(t, files) - b.AssertFileContent("public/s1/p1/index.html",+ b.AssertFileContent(+ "public/s1/p1/index.html", "<p>aaa</p>|content: <p>aaa</p>\n<p>bbb</p>", ) }resources/image.goindex 10df3edda..7058eebb8 100644@@ -322,7 +322,14 @@ func (i *imageResource) Filter(filters ...any) (images.ImageResource, error) { } confMain.Action = images.ActionFilter- confMain.Key = hashing.HashString(gfilters)+ opts := []any{gfilters}+ if images.MainImageVersionNumber > 0 {+ opts = append(opts, images.MainImageVersionNumber)+ }+ if v := images.FormatVersionNumbers[confMain.TargetFormat]; v > 0 {+ opts = append(opts, v)+ }+ confMain.Key = hashing.HashString(opts...) // Geometric filters cannot introduce colors outside the source palette. for _, f := range gfilters {resources/image_test.goindex befb18cf2..c01d8ad35 100644@@ -216,7 +216,7 @@ func TestImageTransformFormat(t *testing.T) { imagePng, err := image.Resize("450x png") c.Assert(err, qt.IsNil)- c.Assert(imagePng.RelPermalink(), qt.Equals, "/a/sunset_hu_63ccccb11ff4e285.png")+ c.Assert(imagePng.RelPermalink(), qt.Equals, "/a/sunset_hu_ae7e4a663628f945.png") c.Assert(imagePng.ResourceType(), qt.Equals, "image") assertExtWidthHeight(imagePng, ".png", 450, 281) c.Assert(imagePng.Name(), qt.Equals, "sunset.jpg")@@ -391,7 +391,7 @@ func TestImageResize8BitPNG(t *testing.T) { resized, err := image.Resize("800x") c.Assert(err, qt.IsNil) c.Assert(resized.MediaType().Type, qt.Equals, "image/png")- c.Assert(resized.RelPermalink(), qt.Equals, "/a/gohugoio_hu_626cfc4db4222bfe.png")+ c.Assert(resized.RelPermalink(), qt.Equals, "/a/gohugoio_hu_3ddd57bfb01f7376.png") c.Assert(resized.Width(), qt.Equals, 800) } resources/images/config.goindex f7d5fc727..4dd859036 100644@@ -84,13 +84,14 @@ var ( // Increment to mark all processed images as stale. Only use when absolutely needed. // See the finer grained smartCropVersionNumber.- mainImageVersionNumber = 1+ MainImageVersionNumber = 1 // Increment a format's version number to mark all processed images targeting // that format as stale, e.g. after a change to its encoder. This is finer // grained than mainImageVersionNumber, which invalidates every format.- formatVersionNumbers = map[Format]int{+ FormatVersionNumbers = map[Format]int{ AVIF: 1,+ PNG: 1, // See issue 12543, 12536 } ) @@ -335,11 +336,11 @@ func DecodeImageConfig(options []string, defaults *config.ConfigNamespace[Imagin return c, err } - if mainImageVersionNumber > 0 {- options = append(options, strconv.Itoa(mainImageVersionNumber))+ if MainImageVersionNumber > 0 {+ options = append(options, strconv.Itoa(MainImageVersionNumber)) } - if v := formatVersionNumbers[c.TargetFormat]; v > 0 {+ if v := FormatVersionNumbers[c.TargetFormat]; v > 0 { options = append(options, "tfv"+strconv.Itoa(v)) } resources/resources_integration_test.goindex 71216e304..69863eaf2 100644@@ -143,9 +143,9 @@ resize 2|RelPermalink: {{ $image.RelPermalink }}|MediaType: {{ $image.MediaType b := hugolib.Test(t, files) b.AssertFileContent("public/index.html",- "jpg|RelPermalink: /images/pixel_hu_38c3f257174fc757.jpg|MediaType: image/jpeg|Width: 1|Height: 1|",- "resize 1|RelPermalink: /images/pixel_hu_b5c2a3d88991f65a.jpg|MediaType: image/jpeg|Width: 20|Height: 30|",- "resize 2|RelPermalink: /images/pixel_hu_b5c2a3d88991f65a.jpg|MediaType: image/jpeg|Width: 20|Height: 30|",+ "jpg|RelPermalink: /images/pixel_hu_43e529ee1951bebf.jpg|MediaType: image/jpeg|Width: 1|Height: 1|",+ "resize 1|RelPermalink: /images/pixel_hu_81fc53effe4c3cf6.jpg|MediaType: image/jpeg|Width: 20|Height: 30|",+ "resize 2|RelPermalink: /images/pixel_hu_81fc53effe4c3cf6.jpg|MediaType: image/jpeg|Width: 20|Height: 30|", ) } resources/transform_test.goindex feae43e41..7f5869ab0 100644@@ -386,15 +386,15 @@ func TestTransform(t *testing.T) { resizedPublished1, err := img.Resize("40x40") c.Assert(err, qt.IsNil) c.Assert(resizedPublished1.Height(), qt.Equals, 40)- c.Assert(resizedPublished1.RelPermalink(), qt.Equals, "/gopher.changed_hu_6347c67500afc377.png")- assertShouldExist(c, spec, "public/gopher.changed_hu_6347c67500afc377.png", true)+ c.Assert(resizedPublished1.RelPermalink(), qt.Equals, "/gopher.changed_hu_dbaf8010a3fe3487.png")+ assertShouldExist(c, spec, "public/gopher.changed_hu_dbaf8010a3fe3487.png", true) // Permalink called. resizedPublished2, err := img.Resize("30x30") c.Assert(err, qt.IsNil) c.Assert(resizedPublished2.Height(), qt.Equals, 30)- c.Assert(resizedPublished2.Permalink(), qt.Equals, "https://example.com/gopher.changed_hu_2d293650135f63d6.png")- assertShouldExist(c, spec, "public/gopher.changed_hu_2d293650135f63d6.png", true)+ c.Assert(resizedPublished2.Permalink(), qt.Equals, "https://example.com/gopher.changed_hu_83657b4754113fc4.png")+ assertShouldExist(c, spec, "public/gopher.changed_hu_83657b4754113fc4.png", true) assertNoDuplicateWrites(c, spec) })testscripts/commands/hugo_gc_mixed_case_cache_dir.txtindex 7c7af1373..b548ccedd 100644@@ -11,7 +11,7 @@ hugo stdout 'Processed images │ 1 ' tree resources/_gen-stdout 'pix_hu_a354833fd576551d.png'+stdout 'pix_hu_51638841a22bb583.png' # Simulate a cache created by an older Hugo version. mv resources/_gen/images/mybundle resources/_gen/images/MyBundle@@ -20,7 +20,7 @@ hugo --gc stdout 'Cleaned │ 0 ' tree resources/_gen-stdout 'pix_hu_a354833fd576551d.png'+stdout 'pix_hu_51638841a22bb583.png' -- hugo.toml -- disableKinds = ["term", "taxonomy", "home"]tpl/images/images_integration_test.goindex 55b541ff1..0969d5972 100644@@ -79,7 +79,8 @@ disableKinds = ['page','rss','section','sitemap','taxonomy','term'] ` b := hugolib.Test(t, files)- b.AssertFileContent("public/index.html",+ b.AssertFileContent(+ "public/index.html", `<img data-id="0" data-img-hash="6ccacf8056c41475" data-level="" data-scale="" data-targetDir="" src="/qr_924bf7d80a564b23.png">`, `<img data-id="1" data-img-hash="6ccacf8056c41475" data-level="medium" data-scale="" data-targetDir="" src="/qr_924bf7d80a564b23.png">`, `<img data-id="2" data-img-hash="6ccacf8056c41475" data-level="medium" data-scale="4" data-targetDir="" src="/qr_924bf7d80a564b23.png">`,@@ -161,8 +162,8 @@ Brightnes func: {{ ($img | images.Filter (images.Brightness 12) ).RelPermalink } b.AssertFileContent("public/index.html", ` images.Config: 222 Resize to 100x100: 100-Brightnes method: /qr_hu_d5f06fd7594d0594.png-Brightnes func: /qr_hu_d5f06fd7594d0594.png+Brightnes method: /qr_hu_e82a6802e23c740e.png+Brightnes func: /qr_hu_e82a6802e23c740e.png `) } @@ -184,8 +185,8 @@ Brightnes func: {{ ($img | images.Filter (images.Brightness 12) ).RelPermalink } b.AssertFileContent("public/index.html", ` images.Config: 222 Resize to 100x100: 100-Brightnes method: /qr_hu_d5f06fd7594d0594.webp-Brightnes func: /qr_hu_d5f06fd7594d0594.webp+Brightnes method: /qr_hu_61e637d0f762ec78.webp+Brightnes func: /qr_hu_61e637d0f762ec78.webp `) } @@ -214,7 +215,7 @@ Image: {{ $img.RelPermalink }} cfg.NeedsOsFS = true cfg.WorkingDir = tempDir }))- b.AssertFileContent("public/index.html", `Image: /qr_hu_6b5f59be9c4d3b3a.webp`)+ b.AssertFileContent("public/index.html", `Image: /qr_hu_7178b50f0d0a9def.webp`) } }tpl/resources/resources_integration_test.goindex b5c611d52..736aee337 100644@@ -60,7 +60,7 @@ Copy3: {{ $copy3.RelPermalink}}|{{ $copy3.MediaType }}|{{ $copy3.Content | safeJ b.AssertFileContent("public/index.html", ` Image Orig: /blog/images/pixel.png|image/png|1|1|-Image Copy1: /blog/images/copy_hu_ef85c36d9b9eff0.png|image/png|3|4|+Image Copy1: /blog/images/copy_hu_e592d810de530dee.png|image/png|3|4| Image Copy2: /blog/images/copy2.png|image/png|3|4| Image Copy3: image/png|3|4| Orig: /blog/js/foo.js|text/javascript|let foo;|@@ -271,7 +271,8 @@ disableKinds = ['page','section','rss','sitemap','taxonomy','term'] b := hugolib.Test(t, files, hugolib.TestOptWarn()) - b.AssertFileContent("public/index.html",+ b.AssertFileContent(+ "public/index.html", ".dartsass{color:red}", ".libsass{color:blue}", )