Skip to content

Commit

Permalink
Add --no-ignore flag to turn off .gitignore/.workignore
Browse files Browse the repository at this point in the history
  • Loading branch information
caitlinelfring committed Sep 3, 2020
1 parent 391983b commit e2fc97e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ Flags:
--debug Enable debug logging
--exit-1-on-failure Exit with exit code 1 on failures
-h, --help help for woke
--no-ignore Files matching entries in .gitignore/.wokeignore are parsed
-o, --output string Output type [text,simple,github-actions] (default "text")
--stdin Read from stdin
-v, --version version for woke
Expand Down
11 changes: 8 additions & 3 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ var (
debug bool
stdin bool
output string
noIgnore bool

// Version is populated by goreleaser during build
// Version...
Expand Down Expand Up @@ -83,9 +84,12 @@ Provide a list file globs for files you'd like to check.`,
return err
}

ignorer, err := ignore.NewIgnore(cfg.IgnoreFiles...)
if err != nil {
return err
var ignorer *ignore.Ignore
if !noIgnore {
ignorer, err = ignore.NewIgnore(cfg.IgnoreFiles...)
if err != nil {
return err
}
}

p := parser.NewParser(cfg.Rules, ignorer)
Expand Down Expand Up @@ -135,6 +139,7 @@ func init() {
rootCmd.PersistentFlags().BoolVar(&exitOneOnFailure, "exit-1-on-failure", false, "Exit with exit code 1 on failures")
rootCmd.PersistentFlags().BoolVar(&stdin, "stdin", false, "Read from stdin")
rootCmd.PersistentFlags().BoolVar(&debug, "debug", false, "Enable debug logging")
rootCmd.PersistentFlags().BoolVar(&noIgnore, "no-ignore", false, "Files matching entries in .gitignore/.wokeignore are parsed")
rootCmd.PersistentFlags().StringVarP(&output, "output", "o", printer.OutFormatText, fmt.Sprintf("Output type [%s]", printer.OutFormatsString))
}

Expand Down
2 changes: 1 addition & 1 deletion pkg/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ func (p *Parser) walkDir(dirname string, done <-chan struct{}) (<-chan string, <
if !info.Mode().IsRegular() {
return nil
}
if p.Ignorer.Match(path) {
if p.Ignorer != nil && p.Ignorer.Match(path) {
return nil
}
if util.IsTextFileFromFilename(path) != nil {
Expand Down

0 comments on commit e2fc97e

Please sign in to comment.