cmd/go: correct go/vcs counter names

Using rr.VCS.Name as done in CL 729500 works for vcsMod, but for all
other VCSes the counter name would've ended up like go/vcs:Mercurial
or go/vcs:Git. Use the Cmd field instead, it should be stable enough.

For golang/go#76801.

Change-Id: Ib36c4fcd49c44ebd7898b5bc40f5d63495cd90e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/774600
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
This commit is contained in:
Dmitri Shuralyov 2026-05-05 19:14:52 -04:00 committed by Gopher Robot
parent 978f00ab7f
commit edc5480072

View file

@ -125,7 +125,7 @@ var vcsList = []*Cmd{
}
// vcsMod is a stub for the "mod" scheme. It's returned by
// repoRootForImportPathDynamic, but is otherwise not treated as a VCS command.
// repoRootForImportDynamic, but is otherwise not treated as a VCS command.
var vcsMod = &Cmd{Name: "mod"}
// vcsByCmd returns the version control system for the given
@ -795,9 +795,13 @@ func RepoRootForImportPath(importPath string, mod ModuleMode, security web.Secur
err = importErrorf(importPath, "cannot expand ... in %q", importPath)
}
// Record telemetry about which VCS was used.
// Record telemetry about which VCS was found.
if err == nil {
counter.Inc("go/vcs:" + rr.VCS.Name)
if rr.VCS == vcsMod {
counter.Inc("go/vcs:mod")
} else {
counter.Inc("go/vcs:" + rr.VCS.Cmd)
}
}
return rr, err