Merge pull request #131 from alaingilbert/fix-ignored_paths
Fix ignored_paths
This commit is contained in:
commit
a30bf93f93
|
@ -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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue