From 42ec64c0e47097e3e827c1f3aaae9f5e54f1a33b Mon Sep 17 00:00:00 2001 From: Meghan Denny Date: Thu, 27 Feb 2020 20:39:57 -0500 Subject: [PATCH] dont check paths in .gitignore --- cmd/misspell/main.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cmd/misspell/main.go b/cmd/misspell/main.go index 174d79d..b976919 100644 --- a/cmd/misspell/main.go +++ b/cmd/misspell/main.go @@ -26,6 +26,9 @@ var ( debug *log.Logger version = "dev" + + gitignoreS, _ = misspell.ReadTextFile(".gitignore") + gitignoreL = strings.Split(gitignoreS, "\n") ) const ( @@ -302,6 +305,21 @@ func main() { for _, filename := range args { filepath.Walk(filename, func(path string, info os.FileInfo, err error) error { if err == nil && !info.IsDir() { + for _, item := range gitignoreL { + if len(item) == 0 { + continue + } + if item[0] == '/' { + // use prefix for absolute paths + if strings.HasPrefix("/"+path, item) { + return nil + } + } else { + if strings.Contains("/"+path, item) { + return nil + } + } + } c <- path } return nil