diff --git a/docs/full_guide.md b/docs/full_guide.md index 35fc3656..04b95051 100644 --- a/docs/full_guide.md +++ b/docs/full_guide.md @@ -451,10 +451,10 @@ LEFTHOOK=0 git commit -am "Lefthook skipped" ## Skip some tags on the fly -Use LEFTHOOK_EXCLUDE={list of tags to be excluded} for that +Use LEFTHOOK_EXCLUDE={list of tags or command names to be excluded} for that ```bash -LEFTHOOK_EXCLUDE=ruby,security git commit -am "Skip some tag checks" +LEFTHOOK_EXCLUDE=ruby,security,lint git commit -am "Skip some tag checks" ``` ## Concurrent files overrides diff --git a/internal/lefthook/runner/runner.go b/internal/lefthook/runner/runner.go index 5e247cd2..6b9e890f 100644 --- a/internal/lefthook/runner/runner.go +++ b/internal/lefthook/runner/runner.go @@ -261,6 +261,11 @@ func (r *Runner) runCommand(name string, command *config.Command) { return } + if intersect(r.hook.ExcludeTags, []string{name}) { + logSkip(name, "(SKIP BY NAME)") + return + } + if err := command.Validate(); err != nil { r.fail(name, "") return diff --git a/internal/lefthook/runner/runner_test.go b/internal/lefthook/runner/runner_test.go index 6673664c..78d70e31 100644 --- a/internal/lefthook/runner/runner_test.go +++ b/internal/lefthook/runner/runner_test.go @@ -101,12 +101,15 @@ func TestRunAll(t *testing.T) { { name: "with exclude tags", hook: &config.Hook{ - ExcludeTags: []string{"tests"}, + ExcludeTags: []string{"tests", "formatter"}, Commands: map[string]*config.Command{ "test": { Run: "success", Tags: []string{"tests"}, }, + "formatter": { + Run: "success", + }, "lint": { Run: "success", Tags: []string{"linters"},