aboutsummaryrefslogtreecommitdiff
path: root/git-codereview/branch_test.go
AgeCommit message (Collapse)Author
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-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: 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>
2021-01-07git-codereview: update tests for "main" branch defaultRuss Cox
"git init ." leaves me on "main" now, not "master". Update tests to expect that, and update the "tracking" message too (otherwise the tests fail). Because not all gits agree about the initial branch name, set it explicitly too in the test. Fixes #42926. Change-Id: If3adb3bb53beba9efcd75cad0f081f59fba85fe7 Reviewed-on: https://go-review.googlesource.com/c/review/+/279873 Trust: Russ Cox <rsc@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Austin Clements <austin@google.com>
2019-12-16git-codereview: write hooks with execute permission in testsBryan C. Mills
The 'write' helper function previously assumed file permission 0666. We don't actually need these files to be world-writable, but we do need specific ones — scripts executed as Git commit hooks — to be executable, at least on certain platforms. Also use t.Helper() to produce more useful log lines for failures. (That was added in order to diagnose TryBot failures.) Fixes golang/go#32836 Change-Id: I2d670563f42778ef8cf645445420756599c37ac6 Reviewed-on: https://go-review.googlesource.com/c/review/+/211477 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alexander Rakoczy <alex@golang.org>
2016-06-14git-codereview: specify --no-track on checkoutJosh Bleecher Snyder
My global git config contains ``` [branch] autosetupmerge = always ``` As a result, git checkout creates a tracking branch, so the current branch is master instead of origin/master. Override the config by specifying --no-track. Fixes golang/go#9379 Change-Id: I00e0f756606f2b7cb2354cb26e8e58eb7cd33274 Reviewed-on: https://go-review.googlesource.com/23969 Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Gerrand <adg@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-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-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-18Revert "git-codereview: fix TestCurrentBranch"Josh Bleecher Snyder
This reverts commit 63cbb9c114be3520f9b7901ecd20db0c8d26bc2a. Change-Id: I3ff7b820378e734fe51bab90c145864f51c39a3d Reviewed-on: https://go-review.googlesource.com/1775 Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2014-12-18git-codereview: fix TestCurrentBranchJosh Bleecher Snyder
Fixes #9379 Change-Id: Ia9122464574355c01e6c457087b0eef9375826e2 Reviewed-on: https://go-review.googlesource.com/1772 Reviewed-by: Chris Manghane <cmang@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>