diff --git a/README.md b/README.md index 4daa38c6..f744d2af 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,14 @@ We have env HOOKAH=0 for that HOOKAH=0 git commit -am "Hookah skipped" ``` +### How can I can skip some tags on the fly? + +We have env HOOKAH_EXCLUDE=tag,tag for that + +```bash +HOOKAH_EXCLUDE=ruby,security git commit -am "Skip some tag checks" +``` + ### How can I run my linter against only modified files? No problem. Lets take `rubocop` linter for ruby as example: diff --git a/cmd/run.go b/cmd/run.go index 24193077..eea5d6d8 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -27,6 +27,7 @@ var ( okList []string failList []string mutex sync.Mutex + envExcludeTags []string // store for HOOKAH_EXCLUDE=tag,tag ) const ( @@ -78,6 +79,10 @@ func RunCmdExecutor(args []string, fs afero.Fs) error { if os.Getenv("HOOKAH") == "0" { return nil } + if tags := os.Getenv("HOOKAH_EXCLUDE"); tags != "" { + envExcludeTags = append(envExcludeTags, strings.Split(tags, ",")[:]...) + } + hooksGroup := args[0] gitArgs := args[1:] var wg sync.WaitGroup @@ -352,11 +357,15 @@ func getTags(hooksGroup, source, executableName string) []string { func getExcludeTags(hooksGroup string) []string { key := strings.Join([]string{hooksGroup, excludeTagsConfigKey}, ".") if len(viper.GetStringSlice(key)) > 0 { - return viper.GetStringSlice(key) + return append(viper.GetStringSlice(key), envExcludeTags[:]...) } if len(viper.GetStringSlice(excludeTagsConfigKey)) > 0 { - return viper.GetStringSlice(excludeTagsConfigKey) + return append(viper.GetStringSlice(excludeTagsConfigKey), envExcludeTags[:]...) + } + + if len(envExcludeTags) > 0 { + return envExcludeTags } return []string{}