@@ -10,7 +10,7 @@ import (
10
10
"github.com/stretchr/testify/assert"
11
11
12
12
"github.com/evilmartians/lefthook/internal/config"
13
- "github.com/evilmartians/lefthook/internal/git "
13
+ "github.com/evilmartians/lefthook/tests/helpers/gittest "
14
14
)
15
15
16
16
func TestLefthookInstall (t * testing.T ) {
@@ -20,17 +20,11 @@ func TestLefthookInstall(t *testing.T) {
20
20
configPath := filepath .Join (root , "lefthook.yml" )
21
21
22
22
hookPath := func (hook string ) string {
23
- return filepath .Join (root , ".git" , "hooks" , hook )
23
+ return filepath .Join (gittest . GitPath ( root ) , "hooks" , hook )
24
24
}
25
25
26
26
infoPath := func (file string ) string {
27
- return filepath .Join (root , ".git" , "info" , file )
28
- }
29
-
30
- repo := & git.Repository {
31
- HooksPath : filepath .Join (root , ".git" , "hooks" ),
32
- RootPath : root ,
33
- InfoPath : filepath .Join (root , ".git" , "info" ),
27
+ return filepath .Join (gittest .GitPath (root ), "info" , file )
34
28
}
35
29
36
30
for n , tt := range [... ]struct {
@@ -219,6 +213,7 @@ post-commit:
219
213
},
220
214
} {
221
215
fs := afero .NewMemMapFs ()
216
+ repo := gittest .NewRepositoryBuilder ().Root (root ).Fs (fs ).Build ()
222
217
lefthook := & Lefthook {
223
218
fs : fs ,
224
219
repo : repo ,
@@ -284,11 +279,6 @@ func Test_syncHooks(t *testing.T) {
284
279
return filepath .Join (root , ".git" , "info" , file )
285
280
}
286
281
287
- repo := & git.Repository {
288
- HooksPath : filepath .Join (root , ".git" , "hooks" ),
289
- RootPath : root ,
290
- InfoPath : filepath .Join (root , ".git" , "info" ),
291
- }
292
282
for n , tt := range [... ]struct {
293
283
name , config , checksum string
294
284
existingHooks map [string ]string
@@ -402,6 +392,7 @@ commit-msg:
402
392
},
403
393
} {
404
394
fs := afero .NewMemMapFs ()
395
+ repo := gittest .NewRepositoryBuilder ().Root (root ).Fs (fs ).Build ()
405
396
lefthook := & Lefthook {
406
397
fs : fs ,
407
398
repo : repo ,
@@ -466,11 +457,6 @@ func TestShouldRefetch(t *testing.T) {
466
457
return filepath .Join (remotePath , ".git" , "FETCH_HEAD" )
467
458
}
468
459
469
- repo := & git.Repository {
470
- HooksPath : filepath .Join (root , ".git" , "hooks" ),
471
- RootPath : root ,
472
- InfoPath : filepath .Join (root , ".git" , "info" ),
473
- }
474
460
for n , tt := range [... ]struct {
475
461
name , config string
476
462
shouldRefetchInitially , shouldRefetchAfter , shouldRefetchBefore bool
@@ -528,6 +514,7 @@ remotes:
528
514
},
529
515
} {
530
516
fs := afero .NewMemMapFs ()
517
+ repo := gittest .NewRepositoryBuilder ().Root (root ).Fs (fs ).Build ()
531
518
lefthook := & Lefthook {
532
519
fs : fs ,
533
520
repo : repo ,
0 commit comments