Skip to content

Commit

Permalink
Fixes filtering of IgnoredPaths to work on the path and not filename,…
Browse files Browse the repository at this point in the history
… add test for it.
  • Loading branch information
groulot committed Jan 11, 2018
1 parent 086ec37 commit 0fe7ff8
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
11 changes: 8 additions & 3 deletions dependency/dependency_file.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,14 +165,19 @@ var getLocalDependencyFiles = func(rootPath string) ([]*api.DependencyFile, erro
}
}
// Skip ignored_pathes

for _, ignoredPath := range config.IgnoredPaths {
matched, err := filepath.Match(filepath.Clean(ignoredPath), info.Name())
// Old behavior, keep it in case users rely on it
matched1, err := filepath.Match(filepath.Clean(ignoredPath), info.Name())
if err != nil {
return err
}
// Actual match on the path
matched2, err := filepath.Match(filepath.Clean(ignoredPath), relativePath)
if err != nil {
return err
}

if matched {
if matched1 || matched2 {
fmt.Println("Skipping", info.Name())
return filepath.SkipDir
}
Expand Down
2 changes: 2 additions & 0 deletions dependency/dependency_file_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
"path/filepath"
"reflect"
"encoding/json"
"github.com/gemnasium/toolbelt/config"
)

type TestFile struct {
Expand Down Expand Up @@ -172,6 +173,7 @@ func TestGetLocalDependencyFiles(t *testing.T) {
b, _ := json.MarshalIndent(v, "", " ")
return string(b)
}
config.IgnoredPaths = []string{"sub1/sub2/Gemfile", "sub3/sub4"}
// Get a list of recognised dependency files from test data
result, err := getLocalDependencyFiles(filepath.Join("testdata", "test_get_local_dependency_files"))
if err != nil {
Expand Down
Empty file.
Empty file.

0 comments on commit 0fe7ff8

Please sign in to comment.