MCPcopy
hub / github.com/github/git-sizer / Init

Method Init

internal/testutils/repoutils.go:45–61  ·  view source on GitHub ↗

Init initializes a git repository at `repo.Path`.

(t *testing.T, bare bool)

Source from the content-addressed store, hash-verified

43
44// Init initializes a git repository at `repo.Path`.
45func (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`.
64func (repo *TestRepo) Remove(t *testing.T) {

Callers 2

TestSubmoduleFunction · 0.95
NewTestRepoFunction · 0.95

Calls 2

CleanGitEnvFunction · 0.85
RunMethod · 0.80

Tested by 1

TestSubmoduleFunction · 0.76