Skip to content

Commit

Permalink
[skip travis] add HOOKAH_EXCLUDE
Browse files Browse the repository at this point in the history
  • Loading branch information
A.A.Abroskin committed Mar 7, 2019
1 parent e5ba09d commit 8a7e8f8
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
13 changes: 11 additions & 2 deletions cmd/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ var (
okList []string
failList []string
mutex sync.Mutex
envExcludeTags []string // store for HOOKAH_EXCLUDE=tag,tag
)

const (
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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{}
Expand Down

0 comments on commit 8a7e8f8

Please sign in to comment.