aboutsummaryrefslogtreecommitdiff
path: root/git-codereview/branch.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
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-08-16git-codereview: fix commentcui fliter
Change-Id: I265d394872a05441ccbf73388e9ff1b625435343 Reviewed-on: https://go-review.googlesource.com/c/review/+/518638 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-04-06git-codereview: handle branches checked out in a worktreeFilippo Valsorda
Change-Id: I085f1d27e9d109a81bc40603b98ebf0d827dfd66 Reviewed-on: https://go-review.googlesource.com/c/review/+/359814 Trust: Filippo Valsorda <filippo@golang.org> Run-TryBot: Filippo Valsorda <filippo@golang.org> Auto-Submit: Filippo Valsorda <filippo@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Russ Cox <rsc@golang.org>
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-13git-codereview: clean up detached HEAD modeRuss Cox
Long ago I decided to return origin/HEAD from b.OriginBranch in detached HEAD mode, thinking it would cause obvious failures. But the joke was on me - origin/HEAD is a real thing in git, and HEAD tracking origin/HEAD is not the right answer on dev branches. Now that each branch's codereview.cfg typically has the branch info we need, we can use that in detached HEAD mode to be able to provide useful displays in commands like "git pending". And we can be careful not to do that when we don't know the actual branch. This commit cleans all that up. Change-Id: I0e59bcb6f9b61e0cdce7a27299b7f29fef8e7048 Reviewed-on: https://go-review.googlesource.com/c/review/+/282616 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
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: allow work on main branchesRuss Cox
The only reason not to allow work on branches named for the origin branches is to preserve them for "git change main; git change new" to make a new branch tracking main. But we can still do that and allow commits on main - we just have to use the branchpoint as the root of the new branch. Now people can work on "main" (or "dev.regabi") if that suits them. In particular, if you're doing merges, it's nice to be on "dev.regabi" and know for sure that's the branch you're working on. Change-Id: I8e9458793c30857a5c00e6bfd4f1cb41adbbe637 Reviewed-on: https://go-review.googlesource.com/c/review/+/279874 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Austin Clements <austin@google.com>
2020-09-11git-codereview: change upstream fallback to try main before masterRuss Cox
Will help when we start using origin/main in Go repos. (Tested using git-codereview against github.com/google/licensecheck.) Change-Id: I564a0f6863938a3196dea3df9e8af240faba91fc Reviewed-on: https://go-review.googlesource.com/c/review/+/254420 Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Andrew Bonventre <andybons@golang.org> TryBot-Result: Gobot Gobot <gobot@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>
2017-11-10git-codereview: overlap 'git fetch -q' with Gerrit queries in pendingRuss Cox
Right now 'git fetch -q' takes about one second because of Gerrit advertising far too many refs. Overlap the fetch with all the other work, to at least reduce the overall time for 'git pending'. The Gerrit team is aware of the refs advertisement problem and a fix is planned for the next few months. That fix will speed things up even further. Change-Id: Iad57da9f1af1c6eae144fe28e5f96f79234bf3cd Reviewed-on: https://go-review.googlesource.com/67572 Reviewed-by: Austin Clements <austin@google.com>
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-10-02git-codereview: avoid Gerrit timeout for missing Change-Id during pendingRuss Cox
If a commit is missing a Change-Id line, pending queries https://go-review.googlesource.com/a/changes/go~master~?o=DETAILED_LABELS&o=CURRENT_REVISION&o=MESSAGES&o=DETAILED_ACCOUNTS (that's go~master~CHANGEID?... with CHANGEID=""), which must cause Gerrit to iterate over all possible CLs or something like that, because it takes forever. Don't bother: if the commit we care about has no Change-Id, it is by definition not on the server at all. This makes 'git pending' not just hang when you have a commit without a Change-Id. Change-Id: I548a51b4190db723538af35ea6a14169861d6bc3 Reviewed-on: https://go-review.googlesource.com/67570 Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Austin Clements <austin@google.com>
2016-10-06review: Fix error of git change on windowsYasuhiro Matsumoto
git change doesn't pass @{u} correctly on windows. The runtime of msys2/cygwin runtime treat @{u] as @u on cmd.exe. This is a workaround for avoiding mis-converting. Fixes golang/go#15036 Change-Id: Ia0389108af69a8b8987ccba1ed933d0767f8efa7 Reviewed-on: https://go-review.googlesource.com/21018 Reviewed-by: Russ Cox <rsc@golang.org>
2016-05-28git-codereview: make change fail with multiple pending changesCaio Marcelo de Oliveira Filho
When using 'git change' to amend the current change, it will fail if there are multiple pending changes. The previous behavior (amending the latest) wasn't always what the user intended. $ git change git-codereview: cannot amend change: multiple changes pending: fc60fd5 test: dummy change 6440cdc git-codereview: make change fail with multiple pending changes $ Unlike mail and submit, change doesn't support explicitly telling which commit to work on. Either 'git commit --amend' (for updating the topmost change) or a combination of 'git commit' and 'git rebase' must be used. Fixes golang/go#10443. Change-Id: I2f6ea1b0e302b66b627761d72d031a3b6aa0fba2 Reviewed-on: https://go-review.googlesource.com/20049 Reviewed-by: Andrew Gerrand <adg@golang.org> Run-TryBot: Andrew Gerrand <adg@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-02-26git-codereview: reject empty commits in mailCaio Marcelo de Oliveira Filho
Fixes golang/go#10753. Change-Id: I224a411177b3d198576a06bc69da9894b7b67c34 Reviewed-on: https://go-review.googlesource.com/19799 Run-TryBot: Andrew Gerrand <adg@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Gerrand <adg@golang.org>
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-12-14git-codereview: fix branch "behind" countAustin Clements
git-codereview pending's count of how far behind a branch is is currently wrong. It computes this from the length of the string printed by git log --format=format:x, but forgets that git log automatically adds new lines between each commit. As a result, given that the true count is n, git pending prints 2n-1. Fix this by counting the number of lines printed by git log, not the number of characters. Change-Id: I5702a833d34333099cad7d88c03837088ac4f9a8 Reviewed-on: https://go-review.googlesource.com/17771 Reviewed-by: Brad Fitzpatrick <bradfitz@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-08-25Revert "review: git change doesn't pass @{u} correctly on windows."Andrew Gerrand
This reverts commit 0d7922879a3c8f00706afeff7e19df53620dfc64. This change fixed the behavior for older versions of Git, but newer versions were unaffected. Let's prioritize newer versions. Change-Id: I7bf3a3653835a800ad5085522660d39ae3770d25 Reviewed-on: https://go-review.googlesource.com/13859 Reviewed-by: Yasuhiro MATSUMOTO <mattn.jp@gmail.com> Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-08-20review: git change doesn't pass @{u} correctly on windows.Yasuhiro Matsumoto
Fixes golang/go#9377 Quote the branch name. Change-Id: Ib35a5dcf7198b94331d894f3bcd825af64b1582d Reviewed-on: https://go-review.googlesource.com/13600 Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-06-17git-codereview: fix missing upstream detectionRuss Cox
With git 2.4.3, the current tests fail (and it breaks in real use): $ go test git rev-parse --abbrev-ref newbranch@{u} fatal: no upstream configured for branch 'newbranch' git-codereview: exit status 128 exit status 1 FAIL golang.org/x/review/git-codereview 0.361s $ The message changed from "No" to "no". Fix detection. Change-Id: I814a7cec612fc12496ef89ccfd80fb70c09d4e46 Reviewed-on: https://go-review.googlesource.com/11172 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
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: parse branch commits correctly during b.PendingRuss Cox
Change-Id: I71b087ec51f6101022e950f783e09e42f7e4e57d Reviewed-on: https://go-review.googlesource.com/2787 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: 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-30git-codereview: guard against ambiguous revision parametersAnthony Martin
Change-Id: I3afcf06e1eab28bfdb2c6ace7aaf774070084900 Reviewed-on: https://go-review.googlesource.com/1783 Reviewed-by: Russ Cox <rsc@golang.org>
2014-12-30git-codereview: make Branch.Submitted pickierJosh Bleecher Snyder
Insist that the search term show up in the output. This prevents unrelated junk output from generating false positives. Treat the search term as a fixed string rather than a regular expression, since that's what it is. Limit the number of matches to 1. git log is fast, but why waste cycles? Updates golang/go#9468 Change-Id: I3ff1ab48785234481543c524a99270b9ecc0ed8e Reviewed-on: https://go-review.googlesource.com/2155 Reviewed-by: Chris Manghane <cmang@golang.org> Reviewed-by: Andrew Gerrand <adg@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: add test for pendingRuss Cox
Fixes #9352 Change-Id: I9714c58ead93d8ec91a09e40a04b1a4e2f075c54 Reviewed-on: https://go-review.googlesource.com/1961 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
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>