From d60c3340ae92fcf395a5db37eb0913c80c43f2fe Mon Sep 17 00:00:00 2001 From: haya14busa Date: Sat, 5 Oct 2019 18:30:56 +0000 Subject: [PATCH] refactoring: move condition --- ghglob.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ghglob.go b/ghglob.go index 051a3bd..d46964e 100644 --- a/ghglob.go +++ b/ghglob.go @@ -70,7 +70,7 @@ func Glob(files chan<- string, patterns []string, opt Option) error { } if typ.IsDir() { - if p != strings.TrimSuffix(rootPrefix, "/") && p != "/" && shouldSkipDir(subms, p) { + if p != strings.TrimSuffix(rootPrefix, "/") && shouldSkipDir(subms, p) { return filepath.SkipDir } return nil @@ -106,7 +106,7 @@ func buildSubMatchers(patterns []string) ([]*ghmatcher.Matcher, error) { } func shouldSkipDir(ms []*ghmatcher.Matcher, path string) bool { - if len(ms) == 0 || path == "." { + if len(ms) == 0 || path == "." || path == "/" { return false } for _, m := range ms {