Fix cascade-pattern-with-extension for cascade in site config

Also clean up the log handling in the integration tester, most notably lost logs during the config loading.

Fixes #12151
This commit is contained in:
Bjørn Erik Pedersen
2024-02-26 16:13:05 +01:00
parent d4be1643a0
commit 1736ef7459
6 changed files with 104 additions and 26 deletions

View File

@@ -98,6 +98,12 @@ func isGlobWithExtension(s string) bool {
return strings.Count(last, ".") > 0
}
func CheckCascadePattern(logger loggers.Logger, m PageMatcher) {
if logger != nil && isGlobWithExtension(m.Path) {
logger.Erroridf("cascade-pattern-with-extension", "cascade target path %q looks like a path with an extension; since Hugo v0.123.0 this will not match anything, see https://gohugo.io/methods/page/path/", m.Path)
}
}
func DecodeCascadeConfig(logger loggers.Logger, in any) (*config.ConfigNamespace[[]PageMatcherParamsConfig, map[PageMatcher]maps.Params], error) {
buildConfig := func(in any) (map[PageMatcher]maps.Params, any, error) {
cascade := make(map[PageMatcher]maps.Params)
@@ -127,9 +133,7 @@ func DecodeCascadeConfig(logger loggers.Logger, in any) (*config.ConfigNamespace
for _, cfg := range cfgs {
m := cfg.Target
if isGlobWithExtension(m.Path) {
logger.Erroridf("cascade-pattern-with-extension", "cascade target path %q looks like a path with an extension; since Hugo v0.123.0 this will not match anything, see https://gohugo.io/methods/page/path/", m.Path)
}
CheckCascadePattern(logger, m)
c, found := cascade[m]
if found {
// Merge