Skip to content

Commit 0920519

Browse files
committed
newGitBomb(): let the caller create the temporary directory
This is simpler, because the caller is also the one that has to clean it up.
1 parent 2b546af commit 0920519

File tree

1 file changed

+10
-13
lines changed

1 file changed

+10
-13
lines changed

git_sizer_test.go

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,12 @@ func addAuthorInfo(cmd *exec.Cmd, timestamp *time.Time) {
6262
}
6363

6464
func newGitBomb(
65-
t *testing.T, repoName string, depth, breadth int, body string,
65+
t *testing.T, path string, depth, breadth int, body string,
6666
) (repo *git.Repository) {
6767
t.Helper()
6868

69-
path, err := ioutil.TempDir("", repoName)
70-
require.NoError(t, err)
71-
72-
defer func() {
73-
if err != nil {
74-
os.RemoveAll(path)
75-
}
76-
}()
77-
7869
cmd := exec.Command("git", "init", "--bare", path)
79-
err = cmd.Run()
70+
err := cmd.Run()
8071
require.NoError(t, err)
8172

8273
repo, err = git.NewRepository(path)
@@ -144,8 +135,14 @@ func TestBomb(t *testing.T) {
144135
t.Parallel()
145136
assert := assert.New(t)
146137

147-
repo := newGitBomb(t, "bomb", 10, 10, "boom!\n")
148-
defer os.RemoveAll(repo.Path())
138+
path, err := ioutil.TempDir("", "bomb")
139+
require.NoError(t, err)
140+
141+
defer func() {
142+
os.RemoveAll(path)
143+
}()
144+
145+
repo := newGitBomb(t, path, 10, 10, "boom!\n")
149146

150147
h, err := sizes.ScanRepositoryUsingGraph(
151148
repo, git.AllReferencesFilter, sizes.NameStyleFull, false,

0 commit comments

Comments
 (0)