aboutsummaryrefslogtreecommitdiff
path: root/git-codereview/api.go
AgeCommit message (Collapse)Author
6 daysgit-codereview: support remote other than "origin"HEADmainShulhan
For the git-codereview commands to works on any Go's repositories, the remote name for "origin" must be pointed to the Go original repository URL (in most cases the one with go.googlesource.com domain). The problem is when the "origin" is from the fork, all of the git-codereview commands then will not works. For example, in computer X, I clone the this repository from "https://go.googlesource.com/review" (the origin) and then push my changes on "git@git.sr.ht:~shulhan/go-x-review" (the fork). In another computer Y, I then clone from the fork to continue my works. The fork become origin. One of the solution is to rename the remote names manually each time we clone the fork. The only cons using this solution is every time new branch created we need to remember to pass "--set-upstream" during git push. This changes introduce "remote" configuration in codereview.cfg. When one first working on fork of Go repository, they set the "remote" key, commit it, and push it. When they cloned the fork, they did not needs to changes anything except adding new remote using the pre-defined name. Change-Id: I335d08fd8b7efe17ba07b3c0a3794f9ccf59b339
2025-10-24git-codereview: fix some commentscuishuang
Change-Id: I0650c81a855138049e9132d56cc742620ecaf185 Reviewed-on: https://go-review.googlesource.com/c/review/+/713362 Reviewed-by: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Sean Liao <sean@liao.dev> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-01-25git-codereview: remove usage of io/ioutilv1.9.0Joshua Sing
io/ioutil is now deprecated. Use non-deprecated equivalents. Change-Id: Iad1cc9c14dbdad3a6f9ada25072bc194bace4081 Reviewed-on: https://go-review.googlesource.com/c/review/+/543615 Reviewed-by: qiulaidongfeng <2645477756@qq.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-06-02git-codereview: recognize sso://go/ and rpc://go/v1.3.0Russ Cox
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>
2022-11-01git-codereview: allow trailing slash in git originv1.2.0Benny Siegert
An origin like "https://go.googlesource.com/build/" should also work. Perhaps this should use net/url instead of parsing URLs by hand. Change-Id: I5304324ae67c054b8377d500ecafe46b296d1531 Reviewed-on: https://go-review.googlesource.com/c/review/+/442875 Reviewed-by: Heschi Kreinick <heschi@google.com> Run-TryBot: Benny Siegert <bsiegert@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-01git-codereview: print more about Gerrit API errorsRuss Cox
For golang/go#50576. Change-Id: I3b67234098cbf9cd28bfa578c0b29744a4add2a3 Reviewed-on: https://go-review.googlesource.com/c/review/+/409914 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2022-04-14git-codereview: print about all Gerrit API errorsRuss Cox
Trying to chase down a problem with slow builders. If this gets to be too chatty, we can limit it to builders. For golang/go#50576. Change-Id: I16c7818153d2444c897b4946ce7baebbd646ab23 Reviewed-on: https://go-review.googlesource.com/c/review/+/399116 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2021-02-23git-codereview: pending: show unresolved comment countRuss Cox
Also fix a potential crash parsing a commit with no parents. Change-Id: I1c289dde45230a3362f54037ea18023278b05ffd Reviewed-on: https://go-review.googlesource.com/c/review/+/294129 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-01-27git-codereview: avoid race in loadGerritOriginIan Lance Taylor
Use a mutex in loadGerritOrigin to avoid race when called in parallel by "git coderevew pending". Add a new initialized field so that the code knows when auth has been initialized. Adjust tests accordingly. The test is simply "go test -race". Fixes golang/go#43670 Change-Id: Ifb060fca6ed463f1d11a2959d03fca5e14e238c6 Reviewed-on: https://go-review.googlesource.com/c/review/+/287012 Trust: Ian Lance Taylor <iant@golang.org> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-03-11git-codereview: remove use of MergeableRuss Cox
Mergeable has been removed from the Gerrit API - it was too expensive to maintain, had racy semantics, and was too little used. As of right now, git submit fails because it doesn't see "mergeable":true in the JSON. Remove the use of it in git-codereview. Change-Id: I12c821b9dbc44183a689d510dd20104eab5a0043 Reviewed-on: https://go-review.googlesource.com/c/review/+/222937 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Bonventre <andybons@golang.org>
2019-11-12git-codereview: pick up URL-specific cookieFile configDaniel Lublin
Example config: [http "https://go.googlesource.com"] cookiefile = ~/.gitcookies-googlesource The --get-urlmatch option falls back to non-URL-specific config. Fixes golang/go#35496 Change-Id: I2410ff5b55e2bf9214fcc2cad16095facec78434 Reviewed-on: https://go-review.googlesource.com/c/review/+/206697 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-06-12git-codereview: use --path option of git config to expand ~Dmitri Shuralyov
This change largely reverts CL 115576, and applies a simpler version. It uses the --path option of git config to achieve equivalent behavior. The --path option is available as far back as git 1.7.0, according to https://git-scm.com/docs/git-config/1.7.0, making it safe to rely on: The type specifier can be [...] --path, which does some path expansion (see --path below). If no type specifier is passed, no checks or transformations are performed on the value. --path git-config will expand leading ~ to the value of $HOME, and ~user to the home directory for the specified user. Change-Id: I74bb543ab488d24fe4cf66da0c6dbc087dc368a6 Reviewed-on: https://go-review.googlesource.com/116016 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-05git-codereview: check for https:// origin only for googlesource urlsMichael Matloob
Change-Id: Idc3ce48cb706959738c6045c3e58904399ca24f3 Reviewed-on: https://go-review.googlesource.com/116361 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-01git-codereview: support ~ in http.cookiefileFilippo Valsorda
http.cookiefile is a pathname value, which means a leading tilde is automatically expanded by git-config. https://git-scm.com/docs/git-config#git-config-httpcookieFile https://git-scm.com/docs/git-config#git-config-pathname Change-Id: Ia208b8a8a7dd5e07de58481b9010051569d0d8c8 Reviewed-on: https://go-review.googlesource.com/115576 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-10git-codereview: batch GerritChange info fetches during pendingRuss Cox
This speeds pending a bit by reducing the number of round trips to the Gerrit server when you have a stack of CLs. Change-Id: I456e1a8739b9b6586f4e05c1a5442f402e440a79 Reviewed-on: https://go-review.googlesource.com/67571 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2016-06-14git-codereview: use codereview.cfg from working treeJosh Bleecher Snyder
Loading codereview.cfg from origin/master effictively means that users have to ask permission to use git-codereview. With this change, users can opt to add the file, .gitignore it, and forget about it. Looking in origin/master also makes it hard to try out git-codereview on a project without having to commit to it. Instead of requiring codereview.cfg be checked in anywhere, just look on the filesystem for it. I can't figure out why I ever thought doing otherwise was a good idea. There are some other related fixes floating around, which might also be good to put in, but this is seems like a good stop-gap, since it is a minimal change; codereview.cfg continues to work for anyone currently using it. Related: golang/go#15616 Related: golang/go#15073 Change-Id: I1e377819f8eb8c8fecf9f022459551a3e8b93d48 Reviewed-on: https://go-review.googlesource.com/24001 Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-05-31review: look in correct location for netrc on Windows.Daniel Theophanes
Change-Id: I38a58a2fb1bf6f4840cca8fe24aaa85ad3d6289e Reviewed-on: https://go-review.googlesource.com/21252 Run-TryBot: Andrew Gerrand <adg@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-05-30review: handle hosting Gerrit in a sub-pathDaniel Theophanes
The git-review module is useful for other gerrit sites. Some host gerrit under a sub-path. Add tests for both googlesource.com repos and non-googlesource.com repos. Change-Id: If2848128d6957db61ac50cbab7e6927da431002b Reviewed-on: https://go-review.googlesource.com/20553 Reviewed-by: Andrew Gerrand <adg@golang.org> Run-TryBot: Andrew Gerrand <adg@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-05-27git-codereview: let codereview.cfg provide "gerrit".Nigel Tao
Change-Id: I3b89b07dd8bb144dbfd3e502c280ed1be2f258a3 Reviewed-on: https://go-review.googlesource.com/10246 Reviewed-by: Andrew Gerrand <adg@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2015-01-19git-codereview: Github URL can be ssh basedMarkus Zimmermann
The remote URL can be something like git@github.com:zimmski/review.git and then it is not detected that a github repository is used. Change-Id: I0e43b7eed2f8d76d2d80ecf415ceee2df25b9254 Reviewed-on: https://go-review.googlesource.com/2975 Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-01-19git-codereview: refactor getOutput/getLines into cmdOutput, trim, lines, ↵Russ Cox
nonBlankLines This CL separates the "run the command and gather output" from the "process output" operations. Doing so makes the desired processing clearer, makes the processing available for use on other text sources. Also, add cmdOutputDir, for running a command in a different directory. This is needed by the gofmt command to work around a bug in Git, and it's made much easier by the above separation. Change-Id: I2addd8b79dab2d4aa8a24c94a8d7b3a16a8e3484 Reviewed-on: https://go-review.googlesource.com/2906 Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-01-06git-codereview: begin to handle multiple-change branchesRuss Cox
Gerrit supports multiple-change branches, and we'd like to make git-codereview useful for people using this mode of work. This CL is the first step. - remove error message on detecting a multiple-change branch - require 'git submit hash' in multiple-change branch - make git submit, git sync cleanup safe for multiple-change branch - adjust git pending output to show full information about multiple-change branch - add pending -c to show only current branch, since output is getting long We're not advertising or supporting this mode yet. For now the only way to enter it is to run 'git commit' to create the second commit. Perhaps eventually we will support something like 'git change -new'. Change-Id: I8284a7c230503061d3e6d7cce0be7d8d05c9b2a3 Reviewed-on: https://go-review.googlesource.com/2110 Reviewed-by: Andrew Gerrand <adg@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2014-12-23git-codereview: fix loadAuth bug from CL 1771Russ Cox
I have a test for this code now. The test found this. The test will be sent in a different, non-TBR CL. Change-Id: I98f5bc22577d7aded284ab9d1bf4fe68b10c2b87 Reviewed-on: https://go-review.googlesource.com/2112 Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-23git-codereview: accept more forms of hosts in cookies fileOling Cat
If the user selects "all of googlesource.com" option when generating the password, the host will be ".googlesource.com", the tool needs to also support this form. Change-Id: Id2669e4b7a7b137c9b99399dbfb8c14dd330b368 Reviewed-on: https://go-review.googlesource.com/1771 Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-22git-codereview: fix .netrc authenticationYann Kerhervé
.netrc credentials were clobbered by missing Git cookiefile. The command to get the output of `git config http.cookiefile` was exiting the program before it got a chance to see if any .netrc file were defined. Remove redundancy in handling error of `git config remote.origin.url`. Change-Id: I1e08710b4e9b154b8fa5ebfb3c2ce72ef4dd2360 Reviewed-on: https://go-review.googlesource.com/1867 Reviewed-by: Andrew Gerrand <adg@golang.org>
2014-12-18git-codereview: rename from 'git-review' to 'git-codereview'Andrew Gerrand
Mostly trivial search and replace, except for hooks.go which includes a special case to remove the old git-review hooks. Change-Id: Ic0792bb3e26607e5e0ead88958e46c3ac08288cd Reviewed-on: https://go-review.googlesource.com/1741 Reviewed-by: Russ Cox <rsc@golang.org>