Commit Graph

9253 Commits

Author SHA1 Message Date
Bjørn Erik Pedersen 91eac9e573 all: Fix some benchmarks broken by modernize
It's not possible to use `b.Loop()` when `b.N` is used to prepare test data.

See 264022a75a
See #14107
2025-11-06 10:43:12 +01:00
Bjørn Erik Pedersen 04650ce778 all: Run modernize -fix ./...
Closes #14107
2025-11-05 21:05:42 +01:00
Bjørn Erik Pedersen 264022a75a Add roles and versions as new dimensions (in addition to language)
See the main issue #13776 for details.

Fixes #519
Fixes #13680
Fixes #13663
Fixes #13776
Fixes #13855
Fixes #13648
Fixes #13996
Fixes #14001
Fixes #14031
Fixes #13818
Fixes #13196
2025-11-05 20:39:25 +01:00
Bjørn Erik Pedersen ff0f67ea7f Update CONTRIBUTING.md 2025-11-04 10:57:26 +01:00
Joe Mooring 2c80dee358 github: Allow AsciiDoc content in tests to render diagrams 2025-10-31 12:47:40 -07:00
Bjørn Erik Pedersen e9bda21ce9 hreflect: Cache reflect method lookups used in collections.Where and others
We already cached the method index on the struct, but caching the resolved `reflect.Method` itself saves us from having to do another lookup on each call, which is escpeciall import in the hot path used by collections.Where and otherrs:

```bash
                                        │ master.bench │    fix-reflectmethodcache.bench     │
                                        │    sec/op    │    sec/op     vs base               │
WhereSliceOfStructPointersWithMethod-10   592.2µ ± ∞ ¹   390.1µ ± ∞ ¹  -34.14% (p=0.029 n=4)
¹ need >= 6 samples for confidence interval at level 0.95

                                        │  master.bench  │     fix-reflectmethodcache.bench     │
                                        │      B/op      │     B/op       vs base               │
WhereSliceOfStructPointersWithMethod-10   205.14Ki ± ∞ ¹   64.52Ki ± ∞ ¹  -68.55% (p=0.029 n=4)
¹ need >= 6 samples for confidence interval at level 0.95

                                        │ master.bench │    fix-reflectmethodcache.bench     │
                                        │  allocs/op   │  allocs/op    vs base               │
WhereSliceOfStructPointersWithMethod-10   9.003k ± ∞ ¹   4.503k ± ∞ ¹  -49.98% (p=0.029 n=4)
````
2025-10-27 15:45:50 +01:00
Bjørn Erik Pedersen 3893e70510 all: Simplify the reflect usage
* Use helper funcs in hreflect package when possible.
* Use hreflect.ConvertIfPossible to handle conversions when possible.
* Move scratch.go from common/maps to common/hstore to clear cyclic import in the next step.
* Move Indirect to hreflect and reimplementing it and adusting the behavior to preserve struct pointers.
* Adjust evaluateSubElem used by where and others making the struct pointer method case slightly faster.
2025-10-26 17:36:58 +01:00
hugoreleaser b95f7d2552 releaser: Prepare repository for 0.153.0-DEV
[ci skip]
2025-10-24 15:44:59 +00:00
hugoreleaser 6abdacad3f releaser: Bump versions for release of 0.152.2
[ci skip]
v0.152.2
2025-10-24 15:31:49 +00:00
Joe Mooring 1c8c21e45e deps: Update github.com/tdewolff/minify v2.24.4 => v2.24.5
Closes #14086
2025-10-24 17:28:42 +02:00
Bjørn Erik Pedersen 809ebe01fa hugofs: Make node_modules a "special case" mount
For this and similar mounts in a theme:

```toml
[[module.mounts]]
source = 'node_modules/bootstrap'
target = 'assets/vendor/bootstrap'
```

We first check the theme itself, then the project root.

For backwards compatibility, we also make any `../../node_modules/...` `source` paths into `node_modules/...` paths when defined in themes/modules.

Fixes #14089
2025-10-24 17:12:46 +02:00
Jordan Elver 08a0679a89 github: Fix typo in stale PR message 2025-10-24 14:30:48 +02:00
hugoreleaser 524b98665b releaser: Prepare repository for 0.153.0-DEV
[ci skip]
2025-10-22 19:24:59 +00:00
hugoreleaser 5869cbddd8 releaser: Bump versions for release of 0.152.1
[ci skip]
v0.152.1
2025-10-22 19:10:44 +00:00
Bjørn Erik Pedersen e08278d165 Expand the numeric conversions to template funcs/methods
So the example mentioned in #14079 also works for TOML and JSON front matter.

See #14079
2025-10-22 21:04:39 +02:00
Bjørn Erik Pedersen df4f80d54f Fix where with uint64
Fixes #14081
2025-10-22 21:04:39 +02:00
Bjørn Erik Pedersen d4c78885ae Fix it so YAML integer types can be used where Go int types are expected
E.g. in date.AddDate.

In Hugo v0.152.0 we moved to a new YAML library (github.com/goccy/go-yaml) which produces uint64 for unsigned integers.

This unfortunately breaks common constructs like:

  .Date.AddDate 0 0 7

when .Date is a time.Time and the integers are unmarshaled from YAML front matter.

This commit adds code to handle conversion from uint64 (and other int types) to the required int types where possible.

Fixes #14079
2025-10-22 21:04:39 +02:00
Bjørn Erik Pedersen 29e2c2fa92 tpl/compare: Fix compare/sort of uint64s
`uint64` is used by github.com/goccy/go-yaml  for unsigned integers, which is the reason why this long-living bug has surfaced now.

Fixes #14078
2025-10-22 13:40:03 +02:00
Bjørn Erik Pedersen 0579afc3c5 Fix "assignment to entry in nil map" on empty YAML config files
Fixes #14074
2025-10-22 13:40:03 +02:00
hugoreleaser 0ccbc63ab8 releaser: Prepare repository for 0.153.0-DEV
[ci skip]
2025-10-21 16:43:50 +00:00
hugoreleaser 06bc2c16c0 releaser: Bump versions for release of 0.152.0
[ci skip]
v0.152.0
2025-10-21 16:29:49 +00:00
Bjørn Erik Pedersen d51adca26a Merge branch 'release-0.151.2' 2025-10-21 16:08:23 +02:00
Bjørn Erik Pedersen a1307700dd config: Clone language map entries before modifying them
Now, with YAML anchor and alias support, these can point to shared data,
which must not be modified in place.

Fixes #14072
2025-10-21 13:34:15 +02:00
Bjørn Erik Pedersen 9425b939c6 Skip flaky test for now
See #14072
2025-10-21 10:32:52 +02:00
Bjørn Erik Pedersen bd50c9c7e7 Misc YAML adjustments
Closes #14067
2025-10-20 16:05:05 +02:00
Bjørn Erik Pedersen a8e0ca9254 hugofs: Make sure that non-project module mounts are local paths
Fixes #14069
2025-10-19 20:27:10 +02:00
Joe Mooring 559a029de7 langs/i18n: Improve reserved key error message
Closes #14061
2025-10-19 13:47:04 +02:00
Bjørn Erik Pedersen 184b10ed45 deps: Upgrade github.com/gohugoio/go-i18n/v2
Gets the fork line with https://github.com/nicksnyder/go-i18n/commit/28dedbee2baafdef1b89b46fc5b729d09232e245 + patch.
2025-10-18 18:21:14 +02:00
Bjørn Erik Pedersen 5bad0d523e langs: Add test case using a "reserved" i18n code
See #14061
2025-10-18 15:28:33 +02:00
Bjørn Erik Pedersen a3d9548469 Replace to gopkg.in/yaml with github.com/goccy/go-yaml (note)
This commit also adds validation to prevent the "Billion Laughs" attack (see https://github.com/goccy/go-yaml/issues/461). The limit of non-scalar aliases to the same node is set to 10,000. See benchmarks below.

```                                                            │        sec/op         │
UnmarshalBillionLaughs/Billion_Laughs_no_validation-10                 125.2µ ± ∞ ¹
UnmarshalBillionLaughs/Billion_Laughs_with_validation-10               655.8µ ± ∞ ¹
UnmarshalBillionLaughs/YAML_Front_Matter_no_validation-10              9.223µ ± ∞ ¹
UnmarshalBillionLaughs/YAML_Front_Matter_with_validation-10            9.443µ ± ∞ ¹
geomean                                                                51.71µ
¹ need >= 6 samples for confidence interval at level 0.95

                                                            │ fix-goyaml-8822.bench │
                                                            │         B/op          │
UnmarshalBillionLaughs/Billion_Laughs_no_validation-10                177.0Ki ± ∞ ¹
UnmarshalBillionLaughs/Billion_Laughs_with_validation-10              177.0Ki ± ∞ ¹
UnmarshalBillionLaughs/YAML_Front_Matter_no_validation-10             11.67Ki ± ∞ ¹
UnmarshalBillionLaughs/YAML_Front_Matter_with_validation-10           11.67Ki ± ∞ ¹
geomean                                                               45.45Ki
¹ need >= 6 samples for confidence interval at level 0.95

                                                            │ fix-goyaml-8822.bench │
                                                            │       allocs/op       │
UnmarshalBillionLaughs/Billion_Laughs_no_validation-10                 3.302k ± ∞ ¹
UnmarshalBillionLaughs/Billion_Laughs_with_validation-10               3.305k ± ∞ ¹
UnmarshalBillionLaughs/YAML_Front_Matter_no_validation-10               253.0 ± ∞ ¹
UnmarshalBillionLaughs/YAML_Front_Matter_with_validation-10             253.0 ± ∞ ¹
````

Fixes #8822
Fixes #13043
Fixes #14053
Fixes ##8427
2025-10-18 13:52:22 +02:00
dependabot[bot] 9e344bbe49 build(deps): bump github.com/tdewolff/minify/v2 from 2.24.3 to 2.24.4
Bumps [github.com/tdewolff/minify/v2](https://github.com/tdewolff/minify) from 2.24.3 to 2.24.4.
- [Release notes](https://github.com/tdewolff/minify/releases)
- [Commits](https://github.com/tdewolff/minify/compare/v2.24.3...v2.24.4)

---
updated-dependencies:
- dependency-name: github.com/tdewolff/minify/v2
  dependency-version: 2.24.4
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-17 18:44:56 +02:00
hugoreleaser 1ec0e2ebec releaser: Prepare repository for 0.152.0-DEV
[ci skip]
2025-10-16 17:06:05 +00:00
hugoreleaser a3574f6f70 releaser: Bump versions for release of 0.151.2
[ci skip]
v0.151.2
2025-10-16 16:52:34 +00:00
Bjørn Erik Pedersen 989454a52d parser/pageparser: Add a testcase for nested shortcodes of the same name
See #14054
2025-10-16 18:50:02 +02:00
Bjørn Erik Pedersen 1e91e46520 parser/pageparser: Fix shortcode nesting regression
This reverts commit a133393eda.

While that commit fixed a bug, it introduced a worse one.

Closes #14054
2025-10-16 18:50:02 +02:00
Bjørn Erik Pedersen 8a57d0f15f testscripts: Add and improve commands tests for static mounts 2025-10-16 12:39:11 +02:00
hugoreleaser b76c50ac18 releaser: Prepare repository for 0.152.0-DEV
[ci skip]
2025-10-15 15:06:42 +00:00
hugoreleaser 1cdd17882c releaser: Bump versions for release of 0.151.1
[ci skip]
v0.151.1
2025-10-15 14:51:34 +00:00
Bjørn Erik Pedersen e2fb0b0e80 Upgrade Go to 1.25.3
See https://go.dev/doc/devel/release#go1.25.3
2025-10-15 13:00:33 +02:00
Kazuo Oishi 88aea56683 tpl: Fix strings/truncate CJK handling
Fix truncate position for mix of CJK and non-CJK text.

Fixes #14039
2025-10-15 13:00:10 +02:00
dependabot[bot] f4c11571bb build(deps): bump github.com/gohugoio/hashstructure from 0.5.0 to 0.6.0
Bumps [github.com/gohugoio/hashstructure](https://github.com/gohugoio/hashstructure) from 0.5.0 to 0.6.0.
- [Release notes](https://github.com/gohugoio/hashstructure/releases)
- [Commits](https://github.com/gohugoio/hashstructure/compare/v0.5.0...v0.6.0)

---
updated-dependencies:
- dependency-name: github.com/gohugoio/hashstructure
  dependency-version: 0.6.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-15 11:00:35 +02:00
dependabot[bot] 54075acc29 build(deps): bump golang.org/x/image from 0.30.0 to 0.32.0
Bumps [golang.org/x/image](https://github.com/golang/image) from 0.30.0 to 0.32.0.
- [Commits](https://github.com/golang/image/compare/v0.30.0...v0.32.0)

---
updated-dependencies:
- dependency-name: golang.org/x/image
  dependency-version: 0.32.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-15 10:59:28 +02:00
dependabot[bot] 8b52303e31 build(deps): bump github.com/evanw/esbuild from 0.25.10 to 0.25.11
Bumps [github.com/evanw/esbuild](https://github.com/evanw/esbuild) from 0.25.10 to 0.25.11.
- [Release notes](https://github.com/evanw/esbuild/releases)
- [Changelog](https://github.com/evanw/esbuild/blob/main/CHANGELOG.md)
- [Commits](https://github.com/evanw/esbuild/compare/v0.25.10...v0.25.11)

---
updated-dependencies:
- dependency-name: github.com/evanw/esbuild
  dependency-version: 0.25.11
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-15 10:57:33 +02:00
dependabot[bot] 3d45d30a41 build(deps): bump golang.org/x/tools from 0.37.0 to 0.38.0
Bumps [golang.org/x/tools](https://github.com/golang/tools) from 0.37.0 to 0.38.0.
- [Release notes](https://github.com/golang/tools/releases)
- [Commits](https://github.com/golang/tools/compare/v0.37.0...v0.38.0)

---
updated-dependencies:
- dependency-name: golang.org/x/tools
  dependency-version: 0.38.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-14 22:10:08 +02:00
dependabot[bot] 095157cd65 build(deps): bump golang.org/x/mod from 0.28.0 to 0.29.0
Bumps [golang.org/x/mod](https://github.com/golang/mod) from 0.28.0 to 0.29.0.
- [Commits](https://github.com/golang/mod/compare/v0.28.0...v0.29.0)

---
updated-dependencies:
- dependency-name: golang.org/x/mod
  dependency-version: 0.29.0
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-10-14 16:34:43 +02:00
Sardorbek Imomaliev 29cf87444f create/skeletons: Wrap section and home lists with section tags
Avoiding issues with tag leakage when using .Summary
See issue #14044 for details.
2025-10-14 11:54:45 +02:00
Joe Mooring 1b4dd436dd markup/goldmark: Align blockquote default output with Goldmark
Closes #14046
2025-10-14 09:38:29 +02:00
Bjørn Erik Pedersen 4414ef73f3 parser/pageparser: Store shortcode names as unique.Handle[string] to save memory allocations
```
                        │ stash.bench  │        perf-pagelexer.bench        │
                        │    sec/op    │    sec/op     vs base              │
ShortcodeLexer-10         68.87µ ± ∞ ¹   65.91µ ± ∞ ¹       ~ (p=0.200 n=4)
Parse-10                  7.421µ ± ∞ ¹   7.030µ ± ∞ ¹  -5.28% (p=0.029 n=4)
HasShortcode/Match-10     70.42n ± ∞ ¹   77.37n ± ∞ ¹  +9.86% (p=0.029 n=4)
HasShortcode/NoMatch-10   14.32n ± ∞ ¹   14.38n ± ∞ ¹       ~ (p=0.086 n=4)
geomean                   847.2n         847.3n        +0.01%
¹ need >= 6 samples for confidence interval at level 0.95

                        │  stash.bench  │         perf-pagelexer.bench          │
                        │     B/op      │     B/op       vs base                │
ShortcodeLexer-10         181.3Ki ± ∞ ¹   177.4Ki ± ∞ ¹  -2.19% (p=0.029 n=4)
Parse-10                  24.56Ki ± ∞ ¹   24.19Ki ± ∞ ¹  -1.53% (p=0.029 n=4)
HasShortcode/Match-10       0.000 ± ∞ ¹     0.000 ± ∞ ¹       ~ (p=1.000 n=4) ²
HasShortcode/NoMatch-10     0.000 ± ∞ ¹     0.000 ± ∞ ¹       ~ (p=1.000 n=4) ²
geomean                               ³                  -0.93%               ³
¹ need >= 6 samples for confidence interval at level 0.95
² all samples are equal
³ summaries must be >0 to compute geomean

                        │ stash.bench  │         perf-pagelexer.bench         │
                        │  allocs/op   │  allocs/op   vs base                 │
ShortcodeLexer-10         1004.0 ± ∞ ¹   921.0 ± ∞ ¹   -8.27% (p=0.029 n=4)
Parse-10                   34.00 ± ∞ ¹   14.00 ± ∞ ¹  -58.82% (p=0.029 n=4)
HasShortcode/Match-10      0.000 ± ∞ ¹   0.000 ± ∞ ¹        ~ (p=1.000 n=4) ²
HasShortcode/NoMatch-10    0.000 ± ∞ ¹   0.000 ± ∞ ¹        ~ (p=1.000 n=4) ²
```
2025-10-05 19:06:46 +02:00
Bjørn Erik Pedersen a133393eda parser/pagerparser: Fix closing shortcode error handling when repeated 2025-10-05 19:06:46 +02:00
Bjørn Erik Pedersen 9197debbfe testscripts: Make test assertion less specific 2025-10-05 18:08:52 +02:00