Skip to content

Commit 59bfc18

Browse files
author
Jay Conrod
committed
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 <[email protected]> Run-TryBot: Jay Conrod <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]>
1 parent cd6f3a5 commit 59bfc18

File tree

3 files changed

+29
-29
lines changed

3 files changed

+29
-29
lines changed

src/cmd/go/internal/modget/query.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -281,14 +281,14 @@ func reportError(q *query, err error) {
281281
// TODO(bcmills): Use errors.As to unpack these errors instead of parsing
282282
// strings with regular expressions.
283283

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

291-
versionRE := regexp.MustCompile("(?m)(?:[ @(\"`]|^)" + regexp.QuoteMeta(q.version) + "(?:[ :)\"`]|$)")
291+
versionRE := regexp.MustCompile("(?m)(?:[ @(\"`]|^)" + regexp.QuoteMeta(q.version) + "(?:[ :;)\"`]|$)")
292292
if versionRE.MatchString(errStr) {
293293
base.Errorf("go get: %s", errStr)
294294
return

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ func checkGOVCS(vcs *Cmd, root string) error {
729729
if private {
730730
what = "private"
731731
}
732-
return fmt.Errorf("GOVCS disallows using %s for %s %s", vcs.Cmd, what, root)
732+
return fmt.Errorf("GOVCS disallows using %s for %s %s; see 'go help vcs'", vcs.Cmd, what, root)
733733
}
734734

735735
return nil

src/cmd/go/testdata/script/govcs.txt

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -5,40 +5,40 @@ env GOPROXY=direct
55
# GOVCS stops go get
66
env GOVCS='*:none'
77
! go get github.com/google/go-cmp
8-
stderr 'go get: GOVCS disallows using git for public github.com/google/go-cmp'
8+
stderr '^go get: GOVCS disallows using git for public github.com/google/go-cmp; see ''go help vcs''$'
99
env GOPRIVATE='github.com/google'
1010
! go get github.com/google/go-cmp
11-
stderr 'go get: GOVCS disallows using git for private github.com/google/go-cmp'
11+
stderr '^go get: GOVCS disallows using git for private github.com/google/go-cmp; see ''go help vcs''$'
1212

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

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

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

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

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

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

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

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

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

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

8787
# Repeat in GOPATH mode. Error texts slightly different.
8888

@@ -91,40 +91,40 @@ env GO111MODULE=off
9191
# GOVCS stops go get
9292
env GOVCS='*:none'
9393
! go get github.com/google/go-cmp
94-
stderr 'package github.com/google/go-cmp: GOVCS disallows using git for public github.com/google/go-cmp'
94+
stderr '^package github.com/google/go-cmp: GOVCS disallows using git for public github.com/google/go-cmp; see ''go help vcs''$'
9595
env GOPRIVATE='github.com/google'
9696
! go get github.com/google/go-cmp
97-
stderr 'package github.com/google/go-cmp: GOVCS disallows using git for private github.com/google/go-cmp'
97+
stderr '^package github.com/google/go-cmp: GOVCS disallows using git for private github.com/google/go-cmp; see ''go help vcs''$'
9898

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

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

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

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

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

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

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

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

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

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

170170
-- go.mod --
171171
module m

0 commit comments

Comments
 (0)