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

Function TestClientCloneCreatesWorkingRepositoryInModifiedRepoDir

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

Source from the content-addressed store, hash-verified

1367}
1368
1369func TestClientCloneCreatesWorkingRepositoryInModifiedRepoDir(t *testing.T) {
1370 // Given a local remote with a trunk commit and an empty destination parent
1371 source := newTestRepo(t)
1372 remote := newBareTestRepo(t)
1373 wantHead := source.commit(t, "remote commit")
1374 source.run(t, "remote", "add", "origin", remote.fileURL())
1375 source.run(t, "push", "--quiet", "origin", "trunk")
1376 parentDir := t.TempDir()
1377 client := &Client{}
1378
1379 // When the remote is cloned using a repository-directory modifier
1380 target, err := client.Clone(t.Context(), remote.fileURL(), nil, WithRepoDir(parentDir))
1381
1382 // Then the reported target contains a working repository on trunk
1383 require.NoError(t, err)
1384 assert.Equal(t, "remote", target)
1385 clonedDir := filepath.Join(parentDir, target)
1386 assert.Equal(t, "false", runGitAt(t, clonedDir, "rev-parse", "--is-bare-repository"))
1387 assert.Equal(t, "trunk", runGitAt(t, clonedDir, "branch", "--show-current"))
1388 assert.Equal(t, wantHead, runGitAt(t, clonedDir, "rev-parse", "HEAD"))
1389}
1390
1391func TestClientCloneCreatesBareRepository(t *testing.T) {
1392 // 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