@@ -25,11 +25,11 @@ func TestExec(t *testing.T) {
25
25
assert .NoErrorf (t , err , "command failed; output: %#v" , string (output ))
26
26
}
27
27
28
- func gitCommand (t * testing.T , repo * git. Repository , args ... string ) * exec.Cmd {
28
+ func gitCommand (t * testing.T , repoPath string , args ... string ) * exec.Cmd {
29
29
t .Helper ()
30
30
31
31
cmd := exec .Command ("git" , args ... )
32
- cmd .Env = append (os .Environ (), "GIT_DIR=" + repo . Path () )
32
+ cmd .Env = append (os .Environ (), "GIT_DIR=" + repoPath )
33
33
return cmd
34
34
}
35
35
@@ -46,7 +46,7 @@ func addFile(t *testing.T, repoPath string, repo *git.Repository, relativePath,
46
46
require .NoErrorf (t , err , "writing to file %q" , filename )
47
47
require .NoErrorf (t , f .Close (), "closing file %q" , filename )
48
48
49
- cmd := gitCommand (t , repo , "add" , relativePath )
49
+ cmd := gitCommand (t , repo . Path () , "add" , relativePath )
50
50
cmd .Dir = repoPath
51
51
require .NoErrorf (t , cmd .Run (), "adding file %q" , relativePath )
52
52
}
@@ -207,21 +207,21 @@ func TestTaggedTags(t *testing.T) {
207
207
208
208
timestamp := time .Unix (1112911993 , 0 )
209
209
210
- cmd = gitCommand (t , repo , "commit" , "-m" , "initial" , "--allow-empty" )
210
+ cmd = gitCommand (t , repo . Path () , "commit" , "-m" , "initial" , "--allow-empty" )
211
211
addAuthorInfo (cmd , & timestamp )
212
212
require .NoError (t , cmd .Run (), "creating commit" )
213
213
214
214
// The lexicographical order of these tags is important, hence
215
215
// their strange names.
216
- cmd = gitCommand (t , repo , "tag" , "-m" , "tag 1" , "tag" , "master" )
216
+ cmd = gitCommand (t , repo . Path () , "tag" , "-m" , "tag 1" , "tag" , "master" )
217
217
addAuthorInfo (cmd , & timestamp )
218
218
require .NoError (t , cmd .Run (), "creating tag 1" )
219
219
220
- cmd = gitCommand (t , repo , "tag" , "-m" , "tag 2" , "bag" , "tag" )
220
+ cmd = gitCommand (t , repo . Path () , "tag" , "-m" , "tag 2" , "bag" , "tag" )
221
221
addAuthorInfo (cmd , & timestamp )
222
222
require .NoError (t , cmd .Run (), "creating tag 2" )
223
223
224
- cmd = gitCommand (t , repo , "tag" , "-m" , "tag 3" , "wag" , "bag" )
224
+ cmd = gitCommand (t , repo . Path () , "tag" , "-m" , "tag 3" , "wag" , "bag" )
225
225
addAuthorInfo (cmd , & timestamp )
226
226
require .NoError (t , cmd .Run (), "creating tag 3" )
227
227
@@ -250,7 +250,7 @@ func TestFromSubdir(t *testing.T) {
250
250
251
251
addFile (t , path , repo , "subdir/file.txt" , "Hello, world!\n " )
252
252
253
- cmd = gitCommand (t , repo , "commit" , "-m" , "initial" )
253
+ cmd = gitCommand (t , repo . Path () , "commit" , "-m" , "initial" )
254
254
addAuthorInfo (cmd , & timestamp )
255
255
require .NoError (t , cmd .Run (), "creating commit" )
256
256
@@ -283,7 +283,7 @@ func TestSubmodule(t *testing.T) {
283
283
addFile (t , submPath , submRepo , "submfile2.txt" , "Hello again, submodule!\n " )
284
284
addFile (t , submPath , submRepo , "submfile3.txt" , "Hello again, submodule!\n " )
285
285
286
- cmd = gitCommand (t , submRepo , "commit" , "-m" , "subm initial" )
286
+ cmd = gitCommand (t , submRepo . Path () , "commit" , "-m" , "subm initial" )
287
287
addAuthorInfo (cmd , & timestamp )
288
288
require .NoError (t , cmd .Run (), "creating subm commit" )
289
289
@@ -294,16 +294,16 @@ func TestSubmodule(t *testing.T) {
294
294
require .NoError (t , err , "initializing main Repository object" )
295
295
addFile (t , mainPath , mainRepo , "mainfile.txt" , "Hello, main!\n " )
296
296
297
- cmd = gitCommand (t , mainRepo , "commit" , "-m" , "main initial" )
297
+ cmd = gitCommand (t , mainRepo . Path () , "commit" , "-m" , "main initial" )
298
298
addAuthorInfo (cmd , & timestamp )
299
299
require .NoError (t , cmd .Run (), "creating main commit" )
300
300
301
301
// Make subm a submodule of main:
302
- cmd = gitCommand (t , mainRepo , "submodule" , "add" , submPath , "sub" )
302
+ cmd = gitCommand (t , mainRepo . Path () , "submodule" , "add" , submPath , "sub" )
303
303
cmd .Dir = mainPath
304
304
require .NoError (t , cmd .Run (), "adding submodule" )
305
305
306
- cmd = gitCommand (t , mainRepo , "commit" , "-m" , "add submodule" )
306
+ cmd = gitCommand (t , mainRepo . Path () , "commit" , "-m" , "add submodule" )
307
307
addAuthorInfo (cmd , & timestamp )
308
308
require .NoError (t , cmd .Run (), "committing submodule to main" )
309
309
0 commit comments