Init initializes a git repository at `repo.Path`.
(t *testing.T, bare bool)
| 43 | |
| 44 | // Init initializes a git repository at `repo.Path`. |
| 45 | func (repo *TestRepo) Init(t *testing.T, bare bool) { |
| 46 | t.Helper() |
| 47 | |
| 48 | // Don't use `GitCommand()` because the directory might not |
| 49 | // exist yet: |
| 50 | var cmd *exec.Cmd |
| 51 | if bare { |
| 52 | //nolint:gosec // `repo.Path` is a path that we created. |
| 53 | cmd = exec.Command("git", "init", "--bare", repo.Path) |
| 54 | } else { |
| 55 | //nolint:gosec // `repo.Path` is a path that we created. |
| 56 | cmd = exec.Command("git", "init", repo.Path) |
| 57 | } |
| 58 | cmd.Env = CleanGitEnv() |
| 59 | err := cmd.Run() |
| 60 | require.NoError(t, err) |
| 61 | } |
| 62 | |
| 63 | // Remove deletes the test repository at `repo.Path`. |
| 64 | func (repo *TestRepo) Remove(t *testing.T) { |