diff options
| author | Filippo Valsorda <filippo@golang.org> | 2021-02-08 00:10:48 +0100 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-04-06 16:00:51 +0000 |
| commit | 8c1fa9c3b8ad0c79f9cefba3bdd8afde5d569f38 (patch) | |
| tree | 39ab70a8f578fe69b5b29a7f863bb816c06d5c13 | |
| parent | de8a882f906a462d2dce15a16b07346147b00c86 (diff) | |
| download | go-x-review-8c1fa9c3b8ad0c79f9cefba3bdd8afde5d569f38.tar.xz | |
git-codereview: fix sync-branch to work in worktrees
Change-Id: I8a3bcad53eae3273dc498ba94d53fe2d50b58520
Reviewed-on: https://go-review.googlesource.com/c/review/+/290212
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>
| -rw-r--r-- | git-codereview/sync.go | 3 | ||||
| -rw-r--r-- | git-codereview/sync_test.go | 24 |
2 files changed, 25 insertions, 2 deletions
diff --git a/git-codereview/sync.go b/git-codereview/sync.go index f8233f1..0555d67 100644 --- a/git-codereview/sync.go +++ b/git-codereview/sync.go @@ -10,7 +10,6 @@ import ( "fmt" "io/ioutil" "os" - "path/filepath" "strings" ) @@ -104,7 +103,7 @@ type syncBranchStatus struct { } func syncBranchStatusFile() string { - return filepath.Join(repoRoot(), ".git/codereview-sync-branch-status") + return gitPath("codereview-sync-branch-status") } func readSyncBranchStatus() *syncBranchStatus { diff --git a/git-codereview/sync_test.go b/git-codereview/sync_test.go index 884168c..1dbd7bf 100644 --- a/git-codereview/sync_test.go +++ b/git-codereview/sync_test.go @@ -7,6 +7,7 @@ package main import ( "bytes" "io/ioutil" + "os" "path/filepath" "strings" "testing" @@ -238,6 +239,29 @@ func TestSyncBranch(t *testing.T) { "Run 'git codereview mail' to send for review.") } +func TestSyncBranchWorktree(t *testing.T) { + gt := newGitTest(t) + defer gt.done() + + gt.serverWork(t) + gt.serverWork(t) + trun(t, gt.server, "git", "checkout", "dev.branch") + gt.serverWorkUnrelated(t, "") + gt.serverWorkUnrelated(t, "") + gt.serverWorkUnrelated(t, "") + trun(t, gt.server, "git", "checkout", "main") + + wt := filepath.Join(gt.tmpdir, "git-worktree") + trun(t, gt.client, "git", "worktree", "add", "-b", "dev.branch", wt, "origin/dev.branch") + if err := os.Chdir(wt); err != nil { + t.Fatal(err) + } + + testMain(t, "sync-branch") + testHideRevHashes(t) + testPrintedStdout(t, "[dev.branch] all: merge main (REVHASH) into dev.branch") +} + func TestSyncBranchMergeBack(t *testing.T) { gt := newGitTest(t) defer gt.done() |
