Skip to content

Commit

Permalink
Set the 'RootFolder' only if it contains 'data' dir
Browse files Browse the repository at this point in the history
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]>
  • Loading branch information
dpordomingo committed Apr 12, 2019
1 parent 3bc7a4c commit 7ac8755
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions fixtures.go
Original file line number Diff line number Diff line change
Expand Up @@ -328,8 +328,7 @@ func Init() error {
rf := filepath.Join(
src, "gopkg.in/src-d/go-git-fixtures.v3",
)

if _, err := os.Stat(rf); err == nil {
if _, err := os.Stat(filepath.Join(rf, DataFolder)); err == nil {
RootFolder = rf
return nil
}
Expand All @@ -338,8 +337,11 @@ func Init() error {
// Try the modules local cache
if dir, err := os.Getwd(); err == nil {
if pkg, err := build.Default.Import("gopkg.in/src-d/go-git-fixtures.v3", dir, build.FindOnly); err == nil {
RootFolder = pkg.Dir
return nil
if _, err := os.Stat(filepath.Join(pkg.Dir, DataFolder)); err == nil {
RootFolder = pkg.Dir
return nil
}

}
}

Expand Down

0 comments on commit 7ac8755

Please sign in to comment.