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

Function TestClientCloneCreatesBareRepository

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

Source from the content-addressed store, hash-verified

1389}
1390
1391func TestClientCloneCreatesBareRepository(t *testing.T) {
1392 // Given a populated local remote and an empty destination parent
1393 source := newTestRepo(t)
1394 remote := newBareTestRepo(t)
1395 wantHead := source.commit(t, "remote commit")
1396 source.run(t, "remote", "add", "origin", remote.fileURL())
1397 source.run(t, "push", "--quiet", "origin", "trunk")
1398 parentDir := t.TempDir()
1399 client := &Client{}
1400
1401 // When the remote is cloned as bare
1402 target, err := client.Clone(t.Context(), remote.fileURL(), []string{"--bare"}, WithRepoDir(parentDir))
1403
1404 // Then the target keeps its .git suffix and contains the trunk ref
1405 require.NoError(t, err)
1406 assert.Equal(t, "remote.git", target)
1407 clonedDir := filepath.Join(parentDir, target)
1408 assert.Equal(t, "true", runGitAt(t, clonedDir, "rev-parse", "--is-bare-repository"))
1409 assert.Equal(t, wantHead, runGitAt(t, clonedDir, "rev-parse", "refs/heads/trunk"))
1410}
1411
1412func TestClientCloneUsesExplicitBareTarget(t *testing.T) {
1413 // Given a populated local remote and an empty destination parent

Callers

nothing calls this directly

Calls 10

CloneMethod · 0.95
newTestRepoFunction · 0.85
newBareTestRepoFunction · 0.85
WithRepoDirFunction · 0.85
runGitAtFunction · 0.85
commitMethod · 0.80
fileURLMethod · 0.80
EqualMethod · 0.80
JoinMethod · 0.80
runMethod · 0.45

Tested by

no test coverage detected