diff options
| author | Russ Cox <rsc@golang.org> | 2021-11-04 11:23:41 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2021-11-06 12:35:55 +0000 |
| commit | 2be698cef0cd8d971fbb4b4d0d7eef0f24aa649e (patch) | |
| tree | 23a22d1e54b82f8aa262d3e0c97340ea6953eb83 /cmd/golangorg/server.go | |
| parent | 70e627117c3a61f48f3fb93c566c9b50a2fe7171 (diff) | |
| download | go-x-website-2be698cef0cd8d971fbb4b4d0d7eef0f24aa649e.tar.xz | |
cmd/golangorg: provide helpful error for git clone https://golang.org/x/repo
People try git clone https://golang.org/x/website (for example)
to clone the website repo. Tell them the right command.
Change-Id: I7dc32190c959afff9908dde0727837b068bfecba
Reviewed-on: https://go-review.googlesource.com/c/website/+/361203
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Diffstat (limited to 'cmd/golangorg/server.go')
| -rw-r--r-- | cmd/golangorg/server.go | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/cmd/golangorg/server.go b/cmd/golangorg/server.go index 905e018e..b1a9d04e 100644 --- a/cmd/golangorg/server.go +++ b/cmd/golangorg/server.go @@ -507,6 +507,15 @@ func xHandler(w http.ResponseWriter, r *http.Request) { http.NotFound(w, r) return } + if suffix == "/info/refs" && strings.HasPrefix(r.URL.Query().Get("service"), "git-") && repo.GoGerritProject != "" { + // Someone is running 'git clone https://golang.org/x/repo'. + // We want the eventual git checkout to have the right origin (go.googlesource.com) + // and not just keep hitting golang.org all the time. + // A redirect would work for this git command but not record the result. + // Instead, print a useful error for the user. + http.Error(w, fmt.Sprintf("Use 'git clone https://go.googlesource.com/%s' instead.", repo.GoGerritProject), http.StatusNotFound) + return + } data := struct { Proj string // Gerrit project ("net", "sys", etc) Suffix string // optional "/path" for requests like /x/PROJ/path |
