Fix ignored_paths

This commit is contained in:
Alain Gilbert 2017-11-23 15:39:20 -08:00
parent 8dbb79377a
commit b1c4fa9abe
No known key found for this signature in database
GPG Key ID: 46DD7443DEDB830D
2 changed files with 4 additions and 2 deletions

View File

@ -397,7 +397,8 @@ func (p *Project) tool(stop <-chan bool, path string) error {
func (p *Project) walk(path string, info os.FileInfo, err error) error { func (p *Project) walk(path string, info os.FileInfo, err error) error {
for _, v := range p.Watcher.Ignore { for _, v := range p.Watcher.Ignore {
s := append([]string{p.Path}, strings.Split(v, string(os.PathSeparator))...) s := append([]string{p.Path}, strings.Split(v, string(os.PathSeparator))...)
if strings.Contains(path, filepath.Join(s...)) { absolutePath, _ := filepath.Abs(filepath.Join(s...))
if path == absolutePath || strings.HasPrefix(path, absolutePath+string(os.PathSeparator)) {
return nil return nil
} }
} }

View File

@ -42,6 +42,7 @@ func TestWalk(t *testing.T) {
{"/go/project", true}, {"/go/project", true},
{"/go/project/main.go", false}, {"/go/project/main.go", false},
{"/go/project/main_test.go", false}, {"/go/project/main_test.go", false},
{"/go/project/vendorish/foo", true},
// invalid relative path // invalid relative path
{"./relative/path", true}, {"./relative/path", true},
{"./relative/path/file.go", false}, {"./relative/path/file.go", false},
@ -66,7 +67,7 @@ func TestWalk(t *testing.T) {
t.Errorf("Exepeted %d files, but was %d", 2, p.files) t.Errorf("Exepeted %d files, but was %d", 2, p.files)
} }
if p.folders != 1 { if p.folders != 2 {
t.Errorf("Exepeted %d folders, but was %d", 2, p.folders) t.Errorf("Exepeted %d folders, but was %d", 2, p.folders)
} }
} }