From 214b208e248d30a3b6c35a5ebf344cc2de3b9e3f Mon Sep 17 00:00:00 2001 From: Dmitri Shuralyov Date: Fri, 25 Apr 2025 19:43:16 -0400 Subject: [PATCH] cmd/go, cmd/internal/objabi: detect "devel" version by substring These were the remaining instances in the main Go repo I found where a Go version like "devel go1.25-9ce47e66e8 Wed Mar 26 03:48:50 2025 -0700" is considered to be a development version rather than a release version, but the version "go1.25-devel_9ce47e66e8 Wed Mar 26 03:48:50 2025 -0700" is not. Update this in preparation of the move of "devel" from front to middle. For #73372. For #73369. Change-Id: If5442ecb0751c08b3a1b4d1148193e501700b956 Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/668355 Reviewed-by: Michael Matloob LUCI-TryBot-Result: Go LUCI Auto-Submit: Dmitri Shuralyov Reviewed-by: Dmitri Shuralyov --- src/cmd/go/internal/work/buildid.go | 4 ++-- src/cmd/internal/objabi/flag.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cmd/go/internal/work/buildid.go b/src/cmd/go/internal/work/buildid.go index 3497ad7a27..9bf3ab9acc 100644 --- a/src/cmd/go/internal/work/buildid.go +++ b/src/cmd/go/internal/work/buildid.go @@ -169,10 +169,10 @@ func (b *Builder) toolID(name string) string { line := stdout.String() f := strings.Fields(line) - if len(f) < 3 || f[0] != name && path != VetTool || f[1] != "version" || f[2] == "devel" && !strings.HasPrefix(f[len(f)-1], "buildID=") { + if len(f) < 3 || f[0] != name && path != VetTool || f[1] != "version" || strings.Contains(f[2], "devel") && !strings.HasPrefix(f[len(f)-1], "buildID=") { base.Fatalf("go: parsing buildID from %s -V=full: unexpected output:\n\t%s", desc, line) } - if f[2] == "devel" { + if strings.Contains(f[2], "devel") { // On the development branch, use the content ID part of the build ID. return contentID(f[len(f)-1]) } diff --git a/src/cmd/internal/objabi/flag.go b/src/cmd/internal/objabi/flag.go index cfd86dc6dc..1bb46e3bcd 100644 --- a/src/cmd/internal/objabi/flag.go +++ b/src/cmd/internal/objabi/flag.go @@ -113,7 +113,7 @@ func (versionFlag) Set(s string) error { // build ID of the binary, so that if the compiler is changed and // rebuilt, we notice and rebuild all packages. if s == "full" { - if strings.HasPrefix(buildcfg.Version, "devel") { + if strings.Contains(buildcfg.Version, "devel") { p += " buildID=" + buildID } }