Skip to content

Commit 33d3625

Browse files
callthingsoffgopherbot
authored andcommitted
cmd/go/internal/vcs: don’t new errors ahead of time in gitRemoteRepo
Also make 'cmd' a const for it is in fact immutable. Change-Id: I3373daa1775e863a378355a355325a7fbdf90485 GitHub-Last-Rev: f669817 GitHub-Pull-Request: #63155 Reviewed-on: https://go-review.googlesource.com/c/go/+/530395 Auto-Submit: Bryan Mills <[email protected]> LUCI-TryBot-Result: Go LUCI <[email protected]> Reviewed-by: Than McIntosh <[email protected]> Reviewed-by: Bryan Mills <[email protected]>
1 parent 66959a5 commit 33d3625

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

src/cmd/go/internal/vcs/vcs.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -283,15 +283,13 @@ var vcsGit = &Cmd{
283283
var scpSyntaxRe = lazyregexp.New(`^(\w+)@([\w.-]+):(.*)$`)
284284

285285
func gitRemoteRepo(vcsGit *Cmd, rootDir string) (remoteRepo string, err error) {
286-
cmd := "config remote.origin.url"
287-
errParse := errors.New("unable to parse output of git " + cmd)
288-
errRemoteOriginNotFound := errors.New("remote origin not found")
286+
const cmd = "config remote.origin.url"
289287
outb, err := vcsGit.run1(rootDir, cmd, nil, false)
290288
if err != nil {
291289
// if it doesn't output any message, it means the config argument is correct,
292290
// but the config value itself doesn't exist
293291
if outb != nil && len(outb) == 0 {
294-
return "", errRemoteOriginNotFound
292+
return "", errors.New("remote origin not found")
295293
}
296294
return "", err
297295
}
@@ -323,7 +321,7 @@ func gitRemoteRepo(vcsGit *Cmd, rootDir string) (remoteRepo string, err error) {
323321
return repoURL.String(), nil
324322
}
325323
}
326-
return "", errParse
324+
return "", errors.New("unable to parse output of git " + cmd)
327325
}
328326

329327
func gitStatus(vcsGit *Cmd, rootDir string) (Status, error) {

0 commit comments

Comments
 (0)