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

Function TestClientCheckoutNewBranchTracksRemoteBranch

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

Source from the content-addressed store, hash-verified

1029}
1030
1031func TestClientCheckoutNewBranchTracksRemoteBranch(t *testing.T) {
1032 // Given a repository with an origin feature tracking ref
1033 repo := newTestRepo(t)
1034 repo.run(t, "commit", "--quiet", "--allow-empty", "-m", "initial commit")
1035 repo.run(t, "remote", "add", "origin", filepath.Join(t.TempDir(), "remote.git"))
1036 repo.run(t, "update-ref", "refs/remotes/origin/feature", "HEAD")
1037
1038 // When a local branch is created from that tracking ref
1039 err := repo.client.CheckoutNewBranch(t.Context(), "origin", "feature")
1040
1041 // Then the new branch is current and tracks origin
1042 require.NoError(t, err)
1043 assert.Equal(t, "feature", repo.run(t, "branch", "--show-current"))
1044 assert.Equal(t, "origin", repo.run(t, "config", "branch.feature.remote"))
1045 assert.Equal(t, "refs/heads/feature", repo.run(t, "config", "branch.feature.merge"))
1046}
1047
1048func TestClientCheckoutNewBranchReportsMissingTrackingBranch(t *testing.T) {
1049 // Given a repository without the requested remote tracking branch

Callers

nothing calls this directly

Calls 5

newTestRepoFunction · 0.85
JoinMethod · 0.80
CheckoutNewBranchMethod · 0.80
EqualMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected