aboutsummaryrefslogtreecommitdiff
path: root/git-codereview/review.go
AgeCommit message (Collapse)Author
6 daysgit-codereview: add command to generate Change-IdShulhan
The codereview commands only works when the git repository remote name is "origin" and on certain URLs. If we execute "codereview change", on repository where "origin" is not pointed to specific URL, the "Change-Id" will generated. This changes is quick solution to manually generate the Change-Id (and add it manually to commit message) until we figure out how to implement commands with different remote name. Change-Id: Ieb155c2f7e097a6a0ec8130698b1c0709a57be0a
2025-07-09git-codereview: frame sync as git codereview syncv1.16.0Matt T. Proud
The codereview binary referred to the sync subcommand as merely "git sync" in a number of places in user surfaces. This was wrong and misleading, so the code now refers to it with the codereview parent subcommand in the name (i.e., a "git codereview sync"). Change-Id: Icf3f96a8c76b57319bc3101b3e9fd0cbd8cecea9 Reviewed-on: https://go-review.googlesource.com/c/review/+/685855 Auto-Submit: Sean Liao <sean@liao.dev> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Sean Liao <sean@liao.dev> Reviewed-by: David Chase <drchase@google.com>
2025-04-11git-codereview: do not write hooks if -n is givenv1.15.0Anatoli Babenia
Fixes golang/go#73314 Change-Id: I881c2ae97f72990a6daac4919687f85cb24ac076 Reviewed-on: https://go-review.googlesource.com/c/review/+/664555 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Bypass: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org>
2025-02-06git-codereview: pending: add -g optionIan Lance Taylor
This is a convenient format for listing changes awaiting review, for pasting into an e-mail or chat. Change-Id: Ib31bf0307d34aaca3e4de4baf9be4c3b3ac60be7 Reviewed-on: https://go-review.googlesource.com/c/review/+/647096 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Commit-Queue: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-10-18git-codereview: make hooks command report conflicting hooksv1.8.0siddharth ravikumar
Display warning message when a hook is already installed and is different from the one installed by git-codereview. Improves upon CL 184417. Fixes golang/go#16777 Change-Id: I7579a3e86572e8b74f92317973e7cc7094b3942d Reviewed-on: https://go-review.googlesource.com/c/review/+/377034 Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2021-02-12git-codereview: fix runDirErr to actually use the passed directoryFilippo Valsorda
Change-Id: I39f16f70e928999674b4f6f60c505ca0a51c46a9 Reviewed-on: https://go-review.googlesource.com/c/review/+/290211 Trust: Filippo Valsorda <filippo@golang.org> Run-TryBot: Filippo Valsorda <filippo@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
2021-01-13git-codereview: add reword commandRuss Cox
Quoting the new docs: The reword command edits pending commit messages. git codereview reword [commit...] Reword opens the editor on the commit message for each named commit in turn. When all the editing is finished, it applies the changes to the pending commits. If no commit is listed, reword applies to the most recent pending commit. Reword is similar in effect to running “git codereview rebase-work” and changing the script action for the named commits to “reword”, or (with no arguments) to “git commit --amend”, but it only affects the commit messages, not the state of the git staged index, nor any checked-out files. This more careful implementation makes it safe to use when there are local changes or, for example, when tests are running that would be broken by temporary changes to the checked-out tree, as would happen during “git codereview rebase-work”. Change-Id: I38ac939b8530bf237c6cafb911f2b17d22eaca60 Reviewed-on: https://go-review.googlesource.com/c/review/+/279718 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-13git-codereview: new sync-branch and related fixesRuss Cox
This CL adds a new command, "git codereview sync-branch", which does the appropriate git merge for the current branch. This CL also fixes a bug in "git codereview branchpoint", and therefore also commands like "git codereview pending", which was getting the branchpoint wrong for merges, with the effect that a merge showed too many pending CLs. This CL also fixes a bug in "git codereview change", which was formerly willing to run "git checkout" with a pending merge, which had the effect of flattening the merge mysteriously. Now it detects the merge and refuses to run. All of this should make merges easier and less error-prone as we use dev branches more often. With the earlier CL in this stack that allows working directly on local branches, this is now a great way to run a merge updating dev.regabi: git change dev.regabi git sync-branch (with appropriate aliases to avoid typing "codereview"). Fixes golang/go#26201. Change-Id: Ic24603123ca5135a72004309f5bb208ff149c9eb Reviewed-on: https://go-review.googlesource.com/c/review/+/279772 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-01-07git-codereview: add a few more testsRuss Cox
Change-Id: I17ad065e8b4c1eb00cdd2f17af82be76bae4fc09 Reviewed-on: https://go-review.googlesource.com/c/review/+/279717 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-12-22git-codereview: clean up usage message, docsRuss Cox
Change-Id: I634a9d47401c1000bcb38e9dd7e84296a3de00e6 Reviewed-on: https://go-review.googlesource.com/c/review/+/254746 Trust: Russ Cox <rsc@golang.org> Trust: Dmitri Shuralyov <dmitshur@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2019-11-09git-codereview: override existing locale with LC_ALL=CEric Lagergren
The git-codereview tool shells out to git, then parses the output. However, because git respects a user's locale settings its output might not be in English, confusing git-codereview. Explicitly set the LC_ALL environment variable to the "C" locale, which is a version of US English that should be on all machines. Fixes golang/go#33895 Change-Id: Id06a81046dba58131fc1de602dd9add687846da1 Reviewed-on: https://go-review.googlesource.com/c/review/+/192237 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-09-25git-codereview: do not install hooks for help and invalid commandsAnderson Queiroz
Fixes golang/go#34320 Change-Id: I53348a027d1a33d1614d2bad32c75eaca52fac8a Reviewed-on: https://go-review.googlesource.com/c/review/+/195897 Run-TryBot: Daniel Martí <mvdan@mvdan.cc> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2018-11-08git-codereview: add -m optionJean de Klerk
The -m option allows a user to specify an inline commit message. This is useful for a few reasons; primary among them are the ability to easily automate a `git change` flow (e.g. in a CI/CD workflow) and the ease of creating one-liner commits (e.g. "regen protos"). Fixes golang/go#24912 Change-Id: Ie06886c74552ec615623c2faac285a1896bdac06 Reviewed-on: https://go-review.googlesource.com/c/107625 Run-TryBot: Yury Smolsky <yury@smolsky.by> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Yury Smolsky <yury@smolsky.by> Reviewed-by: Daniel Martí <mvdan@mvdan.cc> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2018-07-02git-codereview: add -hashtag flag to the mail commandJesús Espino
It is now possible to mail a CL with any number of hashtags. Fixes golang/go#26149 Change-Id: I231826f95ec357bd448de12a9a5aa30e581c3bb3 Reviewed-on: https://go-review.googlesource.com/121798 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>
2017-06-07git-codereview: update help text to add -trybotDaniel Martí
It was added to the godoc in https://golang.org/cl/24960, but that CL missed the help text given in "git-codereview help". Briefly mention it there too. Change-Id: I6905b3f98f4092ed34609596bb875e88cb00d480 Reviewed-on: https://go-review.googlesource.com/41693 Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-06-06codereview: mention rebase-work in usage messageThan McIntosh
Include the 'rebase-work' subcommand in the usage message. Change-Id: I38e5398e89a019669bafeb43429e0bc34988580a Reviewed-on: https://go-review.googlesource.com/44862 Reviewed-by: Austin Clements <austin@google.com>
2016-09-15git-codereview: allow changing to a CLCaio Marcelo de Oliveira Filho
Now 'git change NNNN/PP' can be used to checkout (detached) the git commit corresponding to the patchset PP of the change NNNN. If the patchset is omitted, the current (latest) will be used. Branch names that are only numbers or numbers separated by a slash will always be understood as refering to CL. This break workflows that were using numbers as branch names, but this is expected to be uncommon. The workaround in this case is to use checkout directly. It gets the commit fetching the specific reference inside origin's refs/changes/ and check it out. It uses the gerrit API only if querying the current patchset is needed. Given that it's easy to mistype the number, change to a CL will show the subject of the commit it just checked out. Fixes golang/go#9255. Change-Id: I01b98f4672051a52b8b9110a41d93f3ffefebaf1 Reviewed-on: https://go-review.googlesource.com/20101 Reviewed-by: Andrew Gerrand <adg@golang.org> Run-TryBot: Andrew Gerrand <adg@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-06-14git-codereview: pass args to installHookJosh Bleecher Snyder
This enables passing -v to 'git codereview hooks' to see what commands are being run. It also means that automatic installation of hooks should respect -n. Change-Id: I812685b43e9ea678641f64b2182b957342a4e43c Reviewed-on: https://go-review.googlesource.com/24002 Reviewed-by: Andrew Gerrand <adg@golang.org>
2016-02-18git-codereview: disable Gerrit-specific hook behavior if Gerrit is not in useRuss Cox
Every time I accidentally type 'git pending' in a non-Gerrit repository, that command installs hooks, and then I have to zero the hook files to keep working. First, don't install the hooks if this looks like a non-Gerrit git repo. That seems like it will play well with others. But, people might also want to use the non-Gerrit parts of the tool, so if people do say 'git codereview hooks', let that install them. And then if the hooks are invoked in a non-Gerrit repo, selectively disable the Gerrit-specific parts. For example, if it's not a Gerrit repo we might still want to check and fix 'Fixes #N' lines if directed by the config, but we don't want to add Change-Id lines. Now that things are a bit better behaved, also leave the hooks on in detached head mode. I've found that it's quite frustrating not to have the hooks on when working midway through git rebase -i. If we find reasons that the hooks were off we can try to figure out how to split the difference. Fixes golang/go#12170. Change-Id: I69fa156ce4fd11c0c84416088cd972957ce1ce6d Reviewed-on: https://go-review.googlesource.com/19560 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Austin Clements <austin@google.com>
2016-02-05git-codereview: accept any commit spelling for mail and submitAustin Clements
Currently the mail and submit subcommands only accept commit hashes. This makes them inconsistent with other git commands (git is hard enough without having to remember another convention) and makes working with multi-commit branches cumbersome. Change mail and submit to accept any standard commit spelling. In particular, this makes it possible to use HEAD-relative names: "git mail HEAD" sends the whole current branch. We still require that the named commit be pending on the current branch to avoid accidentally naming a completely unrelated commit. Change-Id: If84d315e0fc32118a5283adfbca7a3b56f3c098c Reviewed-on: https://go-review.googlesource.com/19271 Reviewed-by: Russ Cox <rsc@golang.org>
2015-11-11git-codereview: add interactive mode to submitAustin Clements
This adds a -i option to submit that brings up a list of commits to submit in an editor (a la git rebase -i), lets the user edit the list, and then submits the specified commits in the specified order. Change-Id: I88149140527c987ae856aac2598f0a992fe5654d Reviewed-on: https://go-review.googlesource.com/16677 Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-11-11git-codereview: allow multiple commit hashes for submitAustin Clements
This adds support to the submit subcommand for passing and submitting multiple commit hashes. Change-Id: Id030b07cac21d11acbeb8015fde9cb9e1acb1479 Reviewed-on: https://go-review.googlesource.com/16674 Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-01-30git-codereview: fix bug in sync for multi-commit clientRuss Cox
When deciding whether to discard the commit info for the final commit, it was using the first commit instead of the final one. Change-Id: I2304fba6fa82a1d21600c3caa08b6b119edcdb7f Reviewed-on: https://go-review.googlesource.com/3628 Reviewed-by: Rob Pike <r@golang.org>
2015-01-30git-codereview: use cmd prefix on command implementation funcsRuss Cox
The name space is getting a bit crowded. These words are too easy to use for other variables or functions. Change-Id: Iedbccb82f85627fe422a029a6b45ad39a2e18dd0 Reviewed-on: https://go-review.googlesource.com/3627 Reviewed-by: Rob Pike <r@golang.org>
2015-01-30git-codereview: add rebase-work commandRuss Cox
Shorthand for git rebase -i $(git codereview branchpoint). Suggested alias: rw = codereview rebase-work. Change-Id: I4c489064fc6fced8b18cf528b77ae36b9a1c7f06 Reviewed-on: https://go-review.googlesource.com/3622 Reviewed-by: Rob Pike <r@golang.org>
2015-01-30git-codereview: revise pendingRuss Cox
- Use multiple commit output form always. We're going to start suggesting the use of multiple commits, and it is confusing to flip between the two displays based on the number of commits. - Document pending -c option (current branch only). - Add pending -s option (short form). While doing this, I got my client into a state where I had a tag and a branch with the same name. Make things work in that mode too. Change-Id: I4a3d73ce88be78b04d5bc4e56f1e3bed435cfde7 Reviewed-on: https://go-review.googlesource.com/3621 Reviewed-by: Andrew Gerrand <adg@golang.org> Reviewed-by: Rob Pike <r@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-14git-codereview: add branchpoint command, for scriptsRuss Cox
The most important use of this is git rebase -i $(git codereview branchpoint) in multichange clients. Change-Id: I6bdbc02db2e2823e837159efec20ad5c9046bcd5 Reviewed-on: https://go-review.googlesource.com/2783 Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-01-06git-codereview: add test for loadAuthRuss Cox
Change-Id: Ifdbfc63caa7c1afa42d05c2f91a6168a867e8056 Reviewed-on: https://go-review.googlesource.com/2113 Reviewed-by: Austin Clements <austin@google.com>
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>
2015-01-06git-codereview: allow short user names in git mailRuss Cox
In Mercurial, hg mail expanded Rietveld user names. There are no Gerrit user names. There are GitHub user names, but then I'd have to type randall77,griesemer,robpike,ianlancetaylor instead of khr,gri,r,iant. The algorithm for expanding short user names is as follows: Look at the git commit log for the current repository, extracting all the email addresses in Reviewed-By lines and sorting by how many times each address appears. For each short user name, walk the list, most common address first, and use the first address found that has the short user name on the left side of the @. This is a purely local operation, it adjusts automatically as new reviewers come on board, it avoids a separate database, it adjusts to repo-specific reviewer patterns, and it resolves potential ambiguity in favor of the most common reviewers. (For example, r@golang.org will beat any other r@mail.com in the main repo.) Change-Id: I53afea2a86ba4cfa8fd7f31d56b90a3e12cc2b48 Reviewed-on: https://go-review.googlesource.com/2111 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-01-05git-codereview: print gofmt commands in verbose modeJosh Bleecher Snyder
Change-Id: I589b8daa3504b99374796079bace5a9f4aa0620d Reviewed-on: https://go-review.googlesource.com/2194 Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-23git-codereview: fix a few corner case failuresRuss Cox
- make it clearer what the random git command at the end of failures means - avoid some problems with detached HEAD mode in hooks run during git rebase - redirect all stdout/stderr into test buffers Change-Id: I102f22fc870f69c884728eaa46ecc95792d5b795 Reviewed-on: https://go-review.googlesource.com/2011 Reviewed-by: Andrew Gerrand <adg@golang.org> Reviewed-by: Austin Clements <austin@google.com>
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>