diff options
| author | Russ Cox <rsc@golang.org> | 2021-01-07 12:26:06 -0500 |
|---|---|---|
| committer | Russ Cox <rsc@golang.org> | 2021-01-07 18:26:46 +0000 |
| commit | 5617b8658c4ff7af5665cf0fd4bc5448d4ada7b9 (patch) | |
| tree | 4cd9e48ad8aac87b2e669024fe7605ef7d49317d /git-codereview/change_test.go | |
| parent | 3f3690dc9cf1f7c0ddca72d1c5313be4022ece58 (diff) | |
| download | go-x-review-5617b8658c4ff7af5665cf0fd4bc5448d4ada7b9.tar.xz | |
git-codereview: allow work on main branches
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>
Diffstat (limited to 'git-codereview/change_test.go')
| -rw-r--r-- | git-codereview/change_test.go | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/git-codereview/change_test.go b/git-codereview/change_test.go index 8a3960d..d3b37b0 100644 --- a/git-codereview/change_test.go +++ b/git-codereview/change_test.go @@ -17,11 +17,12 @@ func TestChange(t *testing.T) { t.Logf("main -> main") testMain(t, "change", "main") testRan(t, "git checkout -q main") + branchpoint := strings.TrimSpace(trun(t, gt.client, "git", "rev-parse", "HEAD")) testCommitMsg = "foo: my commit msg" t.Logf("main -> work") testMain(t, "change", "work") - testRan(t, "git checkout -q -b work", + testRan(t, "git checkout -q -b work HEAD", "git branch -q --set-upstream-to origin/main") t.Logf("work -> main") @@ -35,7 +36,12 @@ func TestChange(t *testing.T) { testRan(t, "git checkout -q work", "git commit -q --allow-empty -m foo: my commit msg") - t.Logf("main -> dev.branch") + t.Logf("work -> work2") + testMain(t, "change", "work2") + testRan(t, "git checkout -q -b work2 "+branchpoint, + "git branch -q --set-upstream-to origin/main") + + t.Logf("work2 -> dev.branch") testMain(t, "change", "dev.branch") testRan(t, "git checkout -q -t -b dev.branch origin/dev.branch") @@ -62,19 +68,6 @@ func TestChangeHEAD(t *testing.T) { testPrintedStderr(t, "invalid branch name \"HeAd\": ref name HEAD is reserved for git") } -func TestChangeAhead(t *testing.T) { - gt := newGitTest(t) - defer gt.done() - - // commit to main (mistake) - write(t, gt.client+"/file", "new content", 0644) - trun(t, gt.client, "git", "add", "file") - trun(t, gt.client, "git", "commit", "-m", "msg") - - testMainDied(t, "change", "work") - testPrintedStderr(t, "bad repo state: branch main is ahead of origin/main") -} - func TestMessageRE(t *testing.T) { for _, c := range []struct { in string |
