[go] cmd/go: add hint to read 'go help vcs' to GOVCS errors

36 views
Skip to first unread message

Jay Conrod (Gerrit)

unread,
Jan 8, 2021, 4:14:02 PM1/8/21
to goph...@pubsubhelper.golang.org, golang-co...@googlegroups.com

Jay Conrod has uploaded this change for review.

View Change

cmd/go: add hint to read 'go help vcs' to GOVCS errors

Fixes #43596

Change-Id: Iff925d077b5de64161e88c9471402bc7e8885fcd
---
M src/cmd/go/internal/modget/query.go
M src/cmd/go/internal/vcs/vcs.go
M src/cmd/go/testdata/script/govcs.txt
3 files changed, 29 insertions(+), 29 deletions(-)

diff --git a/src/cmd/go/internal/modget/query.go b/src/cmd/go/internal/modget/query.go
index 20eb0b6..d8364c8 100644
--- a/src/cmd/go/internal/modget/query.go
+++ b/src/cmd/go/internal/modget/query.go
@@ -281,14 +281,14 @@
// TODO(bcmills): Use errors.As to unpack these errors instead of parsing
// strings with regular expressions.

- patternRE := regexp.MustCompile("(?m)(?:[ \t(\"`]|^)" + regexp.QuoteMeta(q.pattern) + "(?:[ @:)\"`]|$)")
+ patternRE := regexp.MustCompile("(?m)(?:[ \t(\"`]|^)" + regexp.QuoteMeta(q.pattern) + "(?:[ @:;)\"`]|$)")
if patternRE.MatchString(errStr) {
if q.rawVersion == "" {
base.Errorf("go get: %s", errStr)
return
}

- versionRE := regexp.MustCompile("(?m)(?:[ @(\"`]|^)" + regexp.QuoteMeta(q.version) + "(?:[ :)\"`]|$)")
+ versionRE := regexp.MustCompile("(?m)(?:[ @(\"`]|^)" + regexp.QuoteMeta(q.version) + "(?:[ :;)\"`]|$)")
if versionRE.MatchString(errStr) {
base.Errorf("go get: %s", errStr)
return
diff --git a/src/cmd/go/internal/vcs/vcs.go b/src/cmd/go/internal/vcs/vcs.go
index 4894ecd..327ea7c 100644
--- a/src/cmd/go/internal/vcs/vcs.go
+++ b/src/cmd/go/internal/vcs/vcs.go
@@ -729,7 +729,7 @@
if private {
what = "private"
}
- return fmt.Errorf("GOVCS disallows using %s for %s %s", vcs.Cmd, what, root)
+ return fmt.Errorf("GOVCS disallows using %s for %s %s; see 'go help vcs'", vcs.Cmd, what, root)
}

return nil
diff --git a/src/cmd/go/testdata/script/govcs.txt b/src/cmd/go/testdata/script/govcs.txt
index 35f092e..4180d7d 100644
--- a/src/cmd/go/testdata/script/govcs.txt
+++ b/src/cmd/go/testdata/script/govcs.txt
@@ -5,40 +5,40 @@
# GOVCS stops go get
env GOVCS='*:none'
! go get github.com/google/go-cmp
-stderr 'go get: GOVCS disallows using git for public github.com/google/go-cmp'
+stderr '^go get: GOVCS disallows using git for public github.com/google/go-cmp; see ''go help vcs''$'
env GOPRIVATE='github.com/google'
! go get github.com/google/go-cmp
-stderr 'go get: GOVCS disallows using git for private github.com/google/go-cmp'
+stderr '^go get: GOVCS disallows using git for private github.com/google/go-cmp; see ''go help vcs''$'

# public pattern works
env GOPRIVATE='github.com/google'
env GOVCS='public:all,private:none'
! go get github.com/google/go-cmp
-stderr 'go get: GOVCS disallows using git for private github.com/google/go-cmp'
+stderr '^go get: GOVCS disallows using git for private github.com/google/go-cmp; see ''go help vcs''$'

# private pattern works
env GOPRIVATE='hubgit.com/google'
env GOVCS='private:all,public:none'
! go get github.com/google/go-cmp
-stderr 'go get: GOVCS disallows using git for public github.com/google/go-cmp'
+stderr '^go get: GOVCS disallows using git for public github.com/google/go-cmp; see ''go help vcs''$'

# other patterns work (for more patterns, see TestGOVCS)
env GOPRIVATE=
env GOVCS='github.com:svn|hg'
! go get github.com/google/go-cmp
-stderr 'go get: GOVCS disallows using git for public github.com/google/go-cmp'
+stderr '^go get: GOVCS disallows using git for public github.com/google/go-cmp; see ''go help vcs''$'
env GOVCS='github.com/google/go-cmp/inner:git,github.com:svn|hg'
! go get github.com/google/go-cmp
-stderr 'go get: GOVCS disallows using git for public github.com/google/go-cmp'
+stderr '^go get: GOVCS disallows using git for public github.com/google/go-cmp; see ''go help vcs''$'

# bad patterns are reported (for more bad patterns, see TestGOVCSErrors)
env GOVCS='git'
! go get github.com/google/go-cmp
-stderr 'go get github.com/google/go-cmp: malformed entry in GOVCS \(missing colon\): "git"'
+stderr '^go get github.com/google/go-cmp: malformed entry in GOVCS \(missing colon\): "git"$'

env GOVCS=github.com:hg,github.com:git
! go get github.com/google/go-cmp
-stderr 'go get github.com/google/go-cmp: unreachable pattern in GOVCS: "github.com:git" after "github.com:hg"'
+stderr '^go get github.com/google/go-cmp: unreachable pattern in GOVCS: "github.com:git" after "github.com:hg"$'

# bad GOVCS patterns do not stop commands that do not need to check VCS
go list
@@ -50,19 +50,19 @@
env GOPRIVATE=
env GOVCS=
! go get rsc.io/nonexist.svn/hello
-stderr 'go get rsc.io/nonexist.svn/hello: GOVCS disallows using svn for public rsc.io/nonexist.svn'
+stderr '^go get rsc.io/nonexist.svn/hello: GOVCS disallows using svn for public rsc.io/nonexist.svn; see ''go help vcs''$'

# fossil is disallowed by default
env GOPRIVATE=
env GOVCS=
! go get rsc.io/nonexist.fossil/hello
-stderr 'go get rsc.io/nonexist.fossil/hello: GOVCS disallows using fossil for public rsc.io/nonexist.fossil'
+stderr '^go get rsc.io/nonexist.fossil/hello: GOVCS disallows using fossil for public rsc.io/nonexist.fossil; see ''go help vcs''$'

# bzr is disallowed by default
env GOPRIVATE=
env GOVCS=
! go get rsc.io/nonexist.bzr/hello
-stderr 'go get rsc.io/nonexist.bzr/hello: GOVCS disallows using bzr for public rsc.io/nonexist.bzr'
+stderr '^go get rsc.io/nonexist.bzr/hello: GOVCS disallows using bzr for public rsc.io/nonexist.bzr; see ''go help vcs''$'

# git is OK by default
env GOVCS=
@@ -77,12 +77,12 @@
# git can be disallowed
env GOVCS=public:hg
! go get rsc.io/nonexist.git/hello
-stderr 'go get rsc.io/nonexist.git/hello: GOVCS disallows using git for public rsc.io/nonexist.git'
+stderr '^go get rsc.io/nonexist.git/hello: GOVCS disallows using git for public rsc.io/nonexist.git; see ''go help vcs''$'

# hg can be disallowed
env GOVCS=public:git
! go get rsc.io/nonexist.hg/hello
-stderr 'go get rsc.io/nonexist.hg/hello: GOVCS disallows using hg for public rsc.io/nonexist.hg'
+stderr '^go get rsc.io/nonexist.hg/hello: GOVCS disallows using hg for public rsc.io/nonexist.hg; see ''go help vcs''$'

# Repeat in GOPATH mode. Error texts slightly different.

@@ -91,40 +91,40 @@
# GOVCS stops go get
env GOVCS='*:none'
! go get github.com/google/go-cmp
-stderr 'package github.com/google/go-cmp: GOVCS disallows using git for public github.com/google/go-cmp'
+stderr '^package github.com/google/go-cmp: GOVCS disallows using git for public github.com/google/go-cmp; see ''go help vcs''$'
env GOPRIVATE='github.com/google'
! go get github.com/google/go-cmp
-stderr 'package github.com/google/go-cmp: GOVCS disallows using git for private github.com/google/go-cmp'
+stderr '^package github.com/google/go-cmp: GOVCS disallows using git for private github.com/google/go-cmp; see ''go help vcs''$'

# public pattern works
env GOPRIVATE='github.com/google'
env GOVCS='public:all,private:none'
! go get github.com/google/go-cmp
-stderr 'package github.com/google/go-cmp: GOVCS disallows using git for private github.com/google/go-cmp'
+stderr '^package github.com/google/go-cmp: GOVCS disallows using git for private github.com/google/go-cmp; see ''go help vcs''$'

# private pattern works
env GOPRIVATE='hubgit.com/google'
env GOVCS='private:all,public:none'
! go get github.com/google/go-cmp
-stderr 'package github.com/google/go-cmp: GOVCS disallows using git for public github.com/google/go-cmp'
+stderr '^package github.com/google/go-cmp: GOVCS disallows using git for public github.com/google/go-cmp; see ''go help vcs''$'

# other patterns work (for more patterns, see TestGOVCS)
env GOPRIVATE=
env GOVCS='github.com:svn|hg'
! go get github.com/google/go-cmp
-stderr 'package github.com/google/go-cmp: GOVCS disallows using git for public github.com/google/go-cmp'
+stderr '^package github.com/google/go-cmp: GOVCS disallows using git for public github.com/google/go-cmp; see ''go help vcs''$'
env GOVCS='github.com/google/go-cmp/inner:git,github.com:svn|hg'
! go get github.com/google/go-cmp
-stderr 'package github.com/google/go-cmp: GOVCS disallows using git for public github.com/google/go-cmp'
+stderr '^package github.com/google/go-cmp: GOVCS disallows using git for public github.com/google/go-cmp; see ''go help vcs''$'

# bad patterns are reported (for more bad patterns, see TestGOVCSErrors)
env GOVCS='git'
! go get github.com/google/go-cmp
-stderr 'package github.com/google/go-cmp: malformed entry in GOVCS \(missing colon\): "git"'
+stderr '^package github.com/google/go-cmp: malformed entry in GOVCS \(missing colon\): "git"$'

env GOVCS=github.com:hg,github.com:git
! go get github.com/google/go-cmp
-stderr 'package github.com/google/go-cmp: unreachable pattern in GOVCS: "github.com:git" after "github.com:hg"'
+stderr '^package github.com/google/go-cmp: unreachable pattern in GOVCS: "github.com:git" after "github.com:hg"$'

# bad GOVCS patterns do not stop commands that do not need to check VCS
go list
@@ -133,19 +133,19 @@
env GOPRIVATE=
env GOVCS=
! go get rsc.io/nonexist.svn/hello
-stderr 'package rsc.io/nonexist.svn/hello: GOVCS disallows using svn for public rsc.io/nonexist.svn'
+stderr '^package rsc.io/nonexist.svn/hello: GOVCS disallows using svn for public rsc.io/nonexist.svn; see ''go help vcs''$'

# fossil is disallowed by default
env GOPRIVATE=
env GOVCS=
! go get rsc.io/nonexist.fossil/hello
-stderr 'package rsc.io/nonexist.fossil/hello: GOVCS disallows using fossil for public rsc.io/nonexist.fossil'
+stderr '^package rsc.io/nonexist.fossil/hello: GOVCS disallows using fossil for public rsc.io/nonexist.fossil; see ''go help vcs''$'

# bzr is disallowed by default
env GOPRIVATE=
env GOVCS=
! go get rsc.io/nonexist.bzr/hello
-stderr 'package rsc.io/nonexist.bzr/hello: GOVCS disallows using bzr for public rsc.io/nonexist.bzr'
+stderr '^package rsc.io/nonexist.bzr/hello: GOVCS disallows using bzr for public rsc.io/nonexist.bzr; see ''go help vcs''$'

# git is OK by default
env GOVCS=
@@ -160,12 +160,12 @@
# git can be disallowed
env GOVCS=public:hg
! go get rsc.io/nonexist.git/hello
-stderr 'package rsc.io/nonexist.git/hello: GOVCS disallows using git for public rsc.io/nonexist.git'
+stderr '^package rsc.io/nonexist.git/hello: GOVCS disallows using git for public rsc.io/nonexist.git; see ''go help vcs''$'

# hg can be disallowed
env GOVCS=public:git
! go get rsc.io/nonexist.hg/hello
-stderr 'package rsc.io/nonexist.hg/hello: GOVCS disallows using hg for public rsc.io/nonexist.hg'
+stderr '^package rsc.io/nonexist.hg/hello: GOVCS disallows using hg for public rsc.io/nonexist.hg; see ''go help vcs''$'

-- go.mod --
module m

To view, visit change 282713. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: go
Gerrit-Branch: master
Gerrit-Change-Id: Iff925d077b5de64161e88c9471402bc7e8885fcd
Gerrit-Change-Number: 282713
Gerrit-PatchSet: 1
Gerrit-Owner: Jay Conrod <jayc...@google.com>
Gerrit-MessageType: newchange

Jay Conrod (Gerrit)

unread,
Jan 8, 2021, 4:14:21 PM1/8/21
to goph...@pubsubhelper.golang.org, Bryan C. Mills, Michael Matloob, golang-co...@googlegroups.com

Attention is currently required from: Bryan C. Mills, Michael Matloob.

Patch set 1:Run-TryBot +1Trust +1

View Change

    To view, visit change 282713. To unsubscribe, or for help writing mail filters, visit settings.

    Gerrit-Project: go
    Gerrit-Branch: master
    Gerrit-Change-Id: Iff925d077b5de64161e88c9471402bc7e8885fcd
    Gerrit-Change-Number: 282713
    Gerrit-PatchSet: 1
    Gerrit-Owner: Jay Conrod <jayc...@google.com>
    Gerrit-Reviewer: Bryan C. Mills <bcm...@google.com>
    Gerrit-Reviewer: Jay Conrod <jayc...@google.com>
    Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
    Gerrit-Attention: Bryan C. Mills <bcm...@google.com>
    Gerrit-Attention: Michael Matloob <mat...@golang.org>
    Gerrit-Comment-Date: Fri, 08 Jan 2021 21:14:16 +0000
    Gerrit-HasComments: No
    Gerrit-Has-Labels: Yes
    Gerrit-MessageType: comment

    Bryan C. Mills (Gerrit)

    unread,
    Jan 8, 2021, 4:35:16 PM1/8/21
    to Jay Conrod, goph...@pubsubhelper.golang.org, Bryan C. Mills, Go Bot, Michael Matloob, golang-co...@googlegroups.com

    Attention is currently required from: Jay Conrod, Michael Matloob.

    Patch set 1:Code-Review +2

    View Change

      To view, visit change 282713. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: Iff925d077b5de64161e88c9471402bc7e8885fcd
      Gerrit-Change-Number: 282713
      Gerrit-PatchSet: 1
      Gerrit-Owner: Jay Conrod <jayc...@google.com>
      Gerrit-Reviewer: Bryan C. Mills <bcm...@google.com>
      Gerrit-Reviewer: Go Bot <go...@golang.org>
      Gerrit-Reviewer: Jay Conrod <jayc...@google.com>
      Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
      Gerrit-Attention: Jay Conrod <jayc...@google.com>
      Gerrit-Attention: Michael Matloob <mat...@golang.org>
      Gerrit-Comment-Date: Fri, 08 Jan 2021 21:35:11 +0000

      Jay Conrod (Gerrit)

      unread,
      Jan 8, 2021, 5:55:46 PM1/8/21
      to goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, Bryan C. Mills, Go Bot, Michael Matloob, golang-co...@googlegroups.com

      Jay Conrod submitted this change.

      View Change

      Approvals: Bryan C. Mills: Looks good to me, approved Jay Conrod: Trusted; Run TryBots Go Bot: TryBots succeeded
      cmd/go: add hint to read 'go help vcs' to GOVCS errors

      Fixes #43596

      Change-Id: Iff925d077b5de64161e88c9471402bc7e8885fcd
      Reviewed-on: https://go-review.googlesource.com/c/go/+/282713
      Trust: Jay Conrod <jayc...@google.com>
      Run-TryBot: Jay Conrod <jayc...@google.com>
      TryBot-Result: Go Bot <go...@golang.org>
      Reviewed-by: Bryan C. Mills <bcm...@google.com>

      To view, visit change 282713. To unsubscribe, or for help writing mail filters, visit settings.

      Gerrit-Project: go
      Gerrit-Branch: master
      Gerrit-Change-Id: Iff925d077b5de64161e88c9471402bc7e8885fcd
      Gerrit-Change-Number: 282713
      Gerrit-PatchSet: 2
      Gerrit-Owner: Jay Conrod <jayc...@google.com>
      Gerrit-Reviewer: Bryan C. Mills <bcm...@google.com>
      Gerrit-Reviewer: Go Bot <go...@golang.org>
      Gerrit-Reviewer: Jay Conrod <jayc...@google.com>
      Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
      Gerrit-MessageType: merged
      Reply all
      Reply to author
      Forward
      0 new messages