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

Function newTestRepoWithMode

git/client_test.go:1565–1591  ·  view source on GitHub ↗
(t *testing.T, bare bool)

Source from the content-addressed store, hash-verified

1563}
1564
1565func newTestRepoWithMode(t *testing.T, bare bool) *testRepo {
1566 t.Helper()
1567 IsolateConfig(t)
1568 // Fail instead of waiting for terminal input if Git requests credentials.
1569 t.Setenv("GIT_TERMINAL_PROMPT", "0")
1570
1571 dir := t.TempDir()
1572 if bare {
1573 dir = filepath.Join(dir, "remote.git")
1574 require.NoError(t, os.Mkdir(dir, 0700))
1575 }
1576 // Git reports resolved paths, such as /private/var instead of /var on macOS.
1577 dir, err := filepath.EvalSymlinks(dir)
1578 require.NoError(t, err)
1579 repo := &testRepo{dir: dir}
1580 repo.client = &Client{RepoDir: repo.dir}
1581 initArgs := []string{"init", "--quiet", "--initial-branch=trunk"}
1582 if bare {
1583 initArgs = append(initArgs, "--bare")
1584 }
1585 repo.run(t, initArgs...)
1586 if !bare {
1587 repo.run(t, "config", "user.name", "GitHub CLI Test")
1588 repo.run(t, "config", "user.email", "gh-test@example.com")
1589 }
1590 return repo
1591}
1592
1593func (r *testRepo) run(t *testing.T, args ...string) string {
1594 t.Helper()

Callers 2

newTestRepoFunction · 0.85
newBareTestRepoFunction · 0.85

Calls 4

runMethod · 0.95
IsolateConfigFunction · 0.85
JoinMethod · 0.80
HelperMethod · 0.65

Tested by

no test coverage detected