MCPcopy Create free account
hub / github.com/cli/cli / TestClientPushRevisionReturnsPushRemoteTrackingRef

Function TestClientPushRevisionReturnsPushRemoteTrackingRef

git/client_test.go:803–822  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

801}
802
803func 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
824func TestClientPushRevisionReportsUnresolvedBranch(t *testing.T) {
825 // Given a repository without the requested branch

Callers

nothing calls this directly

Calls 5

newTestRepoFunction · 0.85
JoinMethod · 0.80
EqualMethod · 0.80
PushRevisionMethod · 0.65
runMethod · 0.45

Tested by

no test coverage detected