(t *testing.T)
| 801 | } |
| 802 | |
| 803 | func TestClientPushRevisionReturnsPushRemoteTrackingRef(t *testing.T) { |
| 804 | // Given a branch that fetches from upstream but pushes to origin |
| 805 | repo := newTestRepo(t) |
| 806 | repo.run(t, "commit", "--quiet", "--allow-empty", "-m", "initial commit") |
| 807 | repo.run(t, "remote", "add", "upstream", filepath.Join(t.TempDir(), "upstream.git")) |
| 808 | repo.run(t, "remote", "add", "origin", filepath.Join(t.TempDir(), "remote.git")) |
| 809 | repo.run(t, "config", "branch.trunk.remote", "upstream") |
| 810 | repo.run(t, "config", "branch.trunk.merge", "refs/heads/main") |
| 811 | repo.run(t, "config", "branch.trunk.pushremote", "origin") |
| 812 | repo.run(t, "config", "push.default", "current") |
| 813 | repo.run(t, "update-ref", "refs/remotes/upstream/main", "HEAD") |
| 814 | repo.run(t, "update-ref", "refs/remotes/origin/trunk", "HEAD") |
| 815 | |
| 816 | // When the branch's push revision is resolved |
| 817 | trackingRef, err := repo.client.PushRevision(t.Context(), "trunk") |
| 818 | |
| 819 | // Then the push remote's current-branch tracking ref is returned rather than the upstream's |
| 820 | require.NoError(t, err) |
| 821 | assert.Equal(t, RemoteTrackingRef{Remote: "origin", Branch: "trunk"}, trackingRef) |
| 822 | } |
| 823 | |
| 824 | func TestClientPushRevisionReportsUnresolvedBranch(t *testing.T) { |
| 825 | // Given a repository without the requested branch |
nothing calls this directly
no test coverage detected