Skip to content

Commit ffa8e24

Browse files
committed
Adding support for use with Go modules
Previous to this patch if you try to run the test of go-git in a Go modules environment, the tests fail due to go-git-fixtures package is not found. In order to found the package on this environment, the build.Context.Import function is leveraged. Signed-off-by: Pablo Andres Fuente <pablo.andres.fuente@gmail.com>
1 parent a75f4e7 commit ffa8e24

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

fixtures.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -328,6 +328,14 @@ func Init() error {
328328
}
329329
}
330330

331+
// Try the modules local cache
332+
if dir, err := os.Getwd(); err == nil {
333+
if pkg, err := build.Default.Import("gopkg.in/src-d/go-git-fixtures.v3", dir, build.FindOnly); err == nil {
334+
RootFolder = pkg.Dir
335+
return nil
336+
}
337+
}
338+
331339
return errors.New("fixtures folder not found")
332340
}
333341

0 commit comments

Comments
 (0)