From 33d3625bf8d0aea69c1a64f8da2ff4efe071d7b0 Mon Sep 17 00:00:00 2001 From: Jes Cok Date: Mon, 25 Sep 2023 15:11:04 +0000 Subject: [PATCH] =?utf8?q?cmd/go/internal/vcs:=20don=E2=80=99t=20new=20err?= =?utf8?q?ors=20ahead=20of=20time=20in=20gitRemoteRepo?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Also make 'cmd' a const for it is in fact immutable. Change-Id: I3373daa1775e863a378355a355325a7fbdf90485 GitHub-Last-Rev: f6698174f53988274c75af83acb267741676b712 GitHub-Pull-Request: golang/go#63155 Reviewed-on: https://go-review.googlesource.com/c/go/+/530395 Auto-Submit: Bryan Mills LUCI-TryBot-Result: Go LUCI Reviewed-by: Than McIntosh Reviewed-by: Bryan Mills --- src/cmd/go/internal/vcs/vcs.go | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/cmd/go/internal/vcs/vcs.go b/src/cmd/go/internal/vcs/vcs.go index a86ed07d3f..4d6cdbca07 100644 --- a/src/cmd/go/internal/vcs/vcs.go +++ b/src/cmd/go/internal/vcs/vcs.go @@ -283,15 +283,13 @@ var vcsGit = &Cmd{ var scpSyntaxRe = lazyregexp.New(`^(\w+)@([\w.-]+):(.*)$`) func gitRemoteRepo(vcsGit *Cmd, rootDir string) (remoteRepo string, err error) { - cmd := "config remote.origin.url" - errParse := errors.New("unable to parse output of git " + cmd) - errRemoteOriginNotFound := errors.New("remote origin not found") + const cmd = "config remote.origin.url" outb, err := vcsGit.run1(rootDir, cmd, nil, false) if err != nil { // if it doesn't output any message, it means the config argument is correct, // but the config value itself doesn't exist if outb != nil && len(outb) == 0 { - return "", errRemoteOriginNotFound + return "", errors.New("remote origin not found") } return "", err } @@ -323,7 +321,7 @@ func gitRemoteRepo(vcsGit *Cmd, rootDir string) (remoteRepo string, err error) { return repoURL.String(), nil } } - return "", errParse + return "", errors.New("unable to parse output of git " + cmd) } func gitStatus(vcsGit *Cmd, rootDir string) (Status, error) { -- 2.50.0