Skip to content

Commit 7ac8755

Browse files
committed
Set the 'RootFolder' only if it contains 'data' dir
It can happen that vendored package, does not contain data directory (ie. when using 'go mod vendor', which does not vendor not linked directories) This should solve it, setting a directory as 'RootFolder' only if it contains 'data' subdirectory Signed-off-by: David Pordomingo <[email protected]>
1 parent 3bc7a4c commit 7ac8755

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

fixtures.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -328,8 +328,7 @@ func Init() error {
328328
rf := filepath.Join(
329329
src, "gopkg.in/src-d/go-git-fixtures.v3",
330330
)
331-
332-
if _, err := os.Stat(rf); err == nil {
331+
if _, err := os.Stat(filepath.Join(rf, DataFolder)); err == nil {
333332
RootFolder = rf
334333
return nil
335334
}
@@ -338,8 +337,11 @@ func Init() error {
338337
// Try the modules local cache
339338
if dir, err := os.Getwd(); err == nil {
340339
if pkg, err := build.Default.Import("gopkg.in/src-d/go-git-fixtures.v3", dir, build.FindOnly); err == nil {
341-
RootFolder = pkg.Dir
342-
return nil
340+
if _, err := os.Stat(filepath.Join(pkg.Dir, DataFolder)); err == nil {
341+
RootFolder = pkg.Dir
342+
return nil
343+
}
344+
343345
}
344346
}
345347

0 commit comments

Comments
 (0)