Backtestshugorun-20261005-133023#15223
commands: Fix "hugo config --lang" flag help text
Our patch was judged better than the merged fix.
In this judgment, Patch A = our agent, Patch B = the merged fix.
Both patches make the same change in commands/config.go and use the suggested help text, so they are equally correct on the core fix. Patch A also adds a testscript. It checks that the new help string appears and the old one does not, which would fail before the change. It also covers the behavior the issue describes: defaultContentLanguage (de) is not first by weight (en), and plain `hugo config` shows the de title. It further tests explicit --lang en/de and the error for an unknown language. Patch A also updates the generated command docs (hugo_config.md) so they match the new help text. That keeps the docs consistent and adds no risk. Patch B makes the minimal correct change but has no tests and leaves the docs stale. On the tests criterion, A is clearly stronger.
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 25m
Wall-clock time in the container
Full test suite
No new failures
3,709 passed · 99 skipped · 3,817 total
Contamination audit
Clean
No sign the agent saw the real fix
Patch size
37vs 2 merged
Changed lines, ours vs merged
The issue
View on GitHubThe --lang flag help says "Defaults to the first language defined", but when
the flag is empty the command uses the default content language:
https://github.com/gohugoio/hugo/blob/master/commands/config.go#L74-L76
These differ when defaultContentLanguage is not first by weight.
Suggested text: "the language to display config for (default is the default content language)"
The two patches
commands/config.goindex 59433b359..d8f20b50b 100644@@ -116,7 +116,7 @@ func (c *configCommand) Init(cd *simplecobra.Commandeer) error { cmd.Long = `Display project configuration, both default and custom settings.` cmd.Flags().StringVar(&c.format, "format", "toml", "preferred file format (toml, yaml or json)") _ = cmd.RegisterFlagCompletionFunc("format", cobra.FixedCompletions([]string{"toml", "yaml", "json"}, cobra.ShellCompDirectiveNoFileComp))- cmd.Flags().StringVar(&c.lang, "lang", "", "the language to display config for. Defaults to the first language defined.")+ cmd.Flags().StringVar(&c.lang, "lang", "", "the language to display config for (default is the default content language)") cmd.Flags().BoolVar(&c.printZero, "printZero", false, `include config options with zero values (e.g. false, 0, "") in the output`) _ = cmd.RegisterFlagCompletionFunc("lang", cobra.NoFileCompletions) applyLocalFlagsBuildConfig(cmd, c.r)docs/content/en/commands/hugo_config.mdindex 3de89f18c..e6b42d0d2 100644@@ -23,7 +23,7 @@ hugo config [command] [flags] -c, --contentDir string filesystem path to content directory --format string preferred file format (toml, yaml or json) (default "toml") -h, --help help for config- --lang string the language to display config for. Defaults to the first language defined.+ --lang string the language to display config for (default is the default content language) --printZero include config options with zero values (e.g. false, 0, "") in the output --renderSegments strings named segments to render (configured in the segments config) -t, --theme strings themes to use (located in /themes/THEMENAME/)testscripts/commands/config__lang.txtnew file mode 100644index 000000000..14c2f21c0@@ -0,0 +1,33 @@+# Test the config command's --lang flag.++hugo config -h+stdout 'the language to display config for \(default is the default content language\)'+! stdout 'Defaults to the first language defined'++# defaultContentLanguage (de) is not the first language by weight (en).+# Without --lang, the default content language config is displayed.+hugo config+stdout '(?m)^title = .Mein Projekt.$'+! stdout '(?m)^title = .My Project.$'++hugo config --lang en+stdout '(?m)^title = .My Project.$'+! stdout '(?m)^title = .Mein Projekt.$'++hugo config --lang de+stdout '(?m)^title = .Mein Projekt.$'+! stdout '(?m)^title = .My Project.$'++! hugo config --lang fr+stderr 'language "fr" not found'++-- hugo.toml --+baseURL = "https://example.com/"+defaultContentLanguage = "de"+[languages]+[languages.en]+weight = 1+title = "My Project"+[languages.de]+weight = 2+title = "Mein Projekt"
commands/config.goindex 59433b359..d8f20b50b 100644@@ -116,7 +116,7 @@ func (c *configCommand) Init(cd *simplecobra.Commandeer) error { cmd.Long = `Display project configuration, both default and custom settings.` cmd.Flags().StringVar(&c.format, "format", "toml", "preferred file format (toml, yaml or json)") _ = cmd.RegisterFlagCompletionFunc("format", cobra.FixedCompletions([]string{"toml", "yaml", "json"}, cobra.ShellCompDirectiveNoFileComp))- cmd.Flags().StringVar(&c.lang, "lang", "", "the language to display config for. Defaults to the first language defined.")+ cmd.Flags().StringVar(&c.lang, "lang", "", "the language to display config for (default is the default content language)") cmd.Flags().BoolVar(&c.printZero, "printZero", false, `include config options with zero values (e.g. false, 0, "") in the output`) _ = cmd.RegisterFlagCompletionFunc("lang", cobra.NoFileCompletions) applyLocalFlagsBuildConfig(cmd, c.r)