@@ -62,12 +62,12 @@ func addAuthorInfo(cmd *exec.Cmd, timestamp *time.Time) {
62
62
}
63
63
64
64
func newGitBomb (
65
- repoName string , depth , breadth int , body string ,
66
- ) (repo * git.Repository , err error ) {
65
+ t * testing.T , repoName string , depth , breadth int , body string ,
66
+ ) (repo * git.Repository ) {
67
+ t .Helper ()
68
+
67
69
path , err := ioutil .TempDir ("" , repoName )
68
- if err != nil {
69
- return nil , err
70
- }
70
+ require .NoError (t , err )
71
71
72
72
defer func () {
73
73
if err != nil {
@@ -77,19 +77,16 @@ func newGitBomb(
77
77
78
78
cmd := exec .Command ("git" , "init" , "--bare" , path )
79
79
err = cmd .Run ()
80
- if err != nil {
81
- return nil , err
82
- }
80
+ require .NoError (t , err )
83
81
84
82
repo , err = git .NewRepository (path )
85
- if err != nil {
86
- return nil , err
87
- }
83
+ require .NoError (t , err )
88
84
89
85
oid , err := repo .CreateObject ("blob" , func (w io.Writer ) error {
90
86
_ , err := io .WriteString (w , body )
91
87
return err
92
88
})
89
+ require .NoError (t , err )
93
90
94
91
digits := len (fmt .Sprintf ("%d" , breadth - 1 ))
95
92
@@ -109,9 +106,7 @@ func newGitBomb(
109
106
}
110
107
return nil
111
108
})
112
- if err != nil {
113
- return nil , err
114
- }
109
+ require .NoError (t , err )
115
110
116
111
mode = "40000"
117
112
prefix = "d"
@@ -129,16 +124,12 @@ func newGitBomb(
129
124
)
130
125
return err
131
126
})
132
- if err != nil {
133
- return nil , err
134
- }
127
+ require .NoError (t , err )
135
128
136
129
err = repo .UpdateRef ("refs/heads/master" , oid )
137
- if err != nil {
138
- return nil , err
139
- }
130
+ require .NoError (t , err )
140
131
141
- return repo , nil
132
+ return repo
142
133
}
143
134
144
135
func pow (x uint64 , n int ) uint64 {
@@ -153,10 +144,7 @@ func TestBomb(t *testing.T) {
153
144
t .Parallel ()
154
145
assert := assert .New (t )
155
146
156
- repo , err := newGitBomb ("bomb" , 10 , 10 , "boom!\n " )
157
- if err != nil {
158
- t .Errorf ("failed to create bomb: %s" , err )
159
- }
147
+ repo := newGitBomb (t , "bomb" , 10 , 10 , "boom!\n " )
160
148
defer os .RemoveAll (repo .Path ())
161
149
162
150
h , err := sizes .ScanRepositoryUsingGraph (
0 commit comments