modules: Ignore non-require blocks in go.mod rewrite

The Go 1.24 tool directive uses single-token entries inside a
tool ( ... ) block. The previous splitter treated any tab-indented
line as a require entry, causing an index out of range panic when
running hugo mod tidy on a module with a tool block.

Track the require block state explicitly so other blocks (tool,
replace, exclude, retract) are left untouched.

Fixes #14783
This commit is contained in:
Bjørn Erik Pedersen
2026-04-20 17:47:12 +02:00
parent 7574e35b40
commit 4169c1f70f
3 changed files with 38 additions and 3 deletions
+8
View File
@@ -11,9 +11,17 @@ go 1.19
require github.com/bep/empty-hugo-module v1.0.0
tool (
github.com/gohugoio/hugo
)
module github.com/gohugoio/testmod
-- golden/go.mod.cleaned --
go 1.19
tool (
github.com/gohugoio/hugo
)
module github.com/gohugoio/testmod