From f16e9861ec0bbc9a82983766fc366932d136a3ce Mon Sep 17 00:00:00 2001 From: caesarsage Date: Sun, 23 Nov 2025 00:08:12 +0100 Subject: [PATCH] Fix: use last match when multiple dependency versions exist --- hack/update/get_version/get_version.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/hack/update/get_version/get_version.go b/hack/update/get_version/get_version.go index b7168f09378e..f2daa96db1b6 100644 --- a/hack/update/get_version/get_version.go +++ b/hack/update/get_version/get_version.go @@ -135,7 +135,15 @@ func main() { if err != nil { log.Fatalf("failed to read file: %v", err) } - submatches := re.FindSubmatch(data) + + // this handles cases where multiple versions exist (e.g., old and new versions in go.mod) + allMatches := re.FindAllSubmatch(data, -1) + if len(allMatches) == 0 { + log.Fatalf("no matches found") + } + + // Take the last match (most recent version) + submatches := allMatches[len(allMatches)-1] if len(submatches) < 2 { log.Fatalf("less than 2 submatches found") }