(t *testing.T, bare bool)
| 1563 | } |
| 1564 | |
| 1565 | func 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 | |
| 1593 | func (r *testRepo) run(t *testing.T, args ...string) string { |
| 1594 | t.Helper() |
no test coverage detected