diff options
| author | Russ Cox <rsc@golang.org> | 2023-06-01 17:06:44 -0400 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2023-06-02 02:03:04 +0000 |
| commit | d285cae025f6e6848090ddb748aade98677328db (patch) | |
| tree | 9b7e0e82accdbfc64111bedd76f12a1154bfb184 /git-codereview/api.go | |
| parent | 197006278d6bfe1d37a22f19be41ed573d66796d (diff) | |
| download | go-x-review-d285cae025f6e6848090ddb748aade98677328db.tar.xz | |
git-codereview: recognize sso://go/ and rpc://go/v1.3.0
Google engineers are now required to use these access methods
instead of https://go.googlesource.com/, so recognize them as
aliases.
(It is possible for every engineer to configure their Git clients with
insteadOf clauses to hide these from the codereview plugin, but
it's far less error-prone to just handle it here.)
Change-Id: Ic1c9a6b45aa61b11ff25ce21bca6e49344974b04
Reviewed-on: https://go-review.googlesource.com/c/review/+/499923
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Diffstat (limited to 'git-codereview/api.go')
| -rw-r--r-- | git-codereview/api.go | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/git-codereview/api.go b/git-codereview/api.go index 947369a..9f7fe23 100644 --- a/git-codereview/api.go +++ b/git-codereview/api.go @@ -88,6 +88,15 @@ func loadGerritOriginInternal(origin, remoteOrigin string) error { return fmt.Errorf("git origin must be a Gerrit host, not GitHub: %s", origin) } + // Google employees are required to use sso://go/ or rpc://go/ + // instead of https://go.googlesource.com/ for git operations. + // Normally that happens with a "insteadOf" in $HOME/.gitconfig, + // but in case people do a git clone from these directly, convert to + // their real meaning. + if strings.HasPrefix(origin, "sso://go/") || strings.HasPrefix(origin, "rpc://go/") { + origin = "https://go.googlesource.com/" + origin[len("sso://go/"):] + } + if googlesourceIndex := strings.Index(origin, ".googlesource.com"); googlesourceIndex >= 0 { if !strings.HasPrefix(origin, "https://") { return fmt.Errorf("git origin must be an https:// URL: %s", origin) @@ -157,7 +166,6 @@ func loadAuth() { if auth.user != "" || auth.cookieName != "" { return } - loadGerritOrigin() // First look in Git's http.cookiefile, which is where Gerrit |
