Repository: evilmartians/lefthook (language: python)

Issue:
`LEFTHOOK_QUIET` enviroment variable doesn't work
### :wrench: Summary

Lefthook doesn't skip any output else if [set the values to the `LEFTHOOK_QUIET` environment variable](https://github.com/evilmartians/lefthook/blob/v1.6.1/docs/usage.md#lefthook_quiet).

### Lefthook version

`1.5.6 dce1a0b6e0e8e9dc38d5376dad15ce29a7f137a8` - `1.6.1 e69adc10c99fd8887673a8b18894082453c6ceaf`

Lefthook v1.5.5 doesn't have the problem.

### Steps to reproduce

Run the following bash script.

`reproduce.sh`

``` bash
#!/usr/bin/env bash

mkdir not_work_LEFTHOOK_QUIET
cd not_work_LEFTHOOK_QUIET

git init --quiet

cat<<'HERE'>lefthook.toml
[foo]
[foo.commands]
[foo.commands.bar]
run = 'echo Hello World'
HERE

run_lefthook() {
  filename="lefthook_$1"

  wget \
    --quiet \
    --output-document="$filename" \
    https://github.com/evilmartians/lefthook/releases/download/v"$1"/lefthook_"$1"_Linux_x86_64

  chmod +x "$filename"

  export LEFTHOOK_QUIET=meta,summary,empty_summary,execution

  echo "========================================="
  printf 'version: %s\n' "$(./"$filename" version -f)"
  echo "========================================="
  set -x
  ./"$filename" install
  ./"$filename" run foo
  set +x
}

for patch_version in 5 6; do
  run_lefthook "1.5.$patch_version"
done
```

- OS: Ubuntu 20.04 (WSL2)

### Expected results

``` console
$ LEFTHOOK_QUIET=meta,summary,empty_summary,execution lefthook run foo
$
```

### Actual results

``` console
$ LEFTHOOK_QUIET=meta,summary,empty_summary,execution lefthook run foo
╭───────────────────────────────╮
│ 🥊 lefthook v1.5.6  hook: foo │
╰───────────────────────────────╯
┃  bar ❯

Hello World


  ────────────────────────────────────
summary: (done in 0.00 seconds)
✔️  bar
$
```

### Possible Solution

Lefthook have had the problem since the f32e497a9813b5495ba33f7bf6d9c6acc259d79a commit.

If `LEFTHOOK_QUITE=''` disable all output like a [`skip_output: false` of Lefthook configuration](https://github.com/evilmartians/lefthook/blob/v1.6.1/docs/configuration.md#skip_output), I would be happy.

### Logs / Screenshots

``` console
$ LEFTHOOK_VERBOSE=1 bash reproduce.sh
=========================================
version: 1.5.5 9b072e6622857ceb8d40a173ba39ae97afb35957
=========================================
+ ./lefthook_1.5.5 install
│ [lefthook] cmd: [git rev-parse --show-toplevel]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: /home/hituzi_no_sippo/workspace/my_projects/hooks_for_lefthook/reproduce/not_work_LEFTHOOK_QUIET

│ [lefthook] cmd: [git rev-parse --git-path hooks]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git/hooks

│ [lefthook] cmd: [git rev-parse --git-path info]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git/info

│ [lefthook] cmd: [git rev-parse --git-dir]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git

│ Searching config in:/home/hituzi_no_sippo/workspace/my_projects/hooks_for_lefthook/reproduce/not_work_LEFTHOOK_QUIET
sync hooks: ✔️ (foo)
+ ./lefthook_1.5.5 run foo
│ [lefthook] cmd: [git rev-parse --show-toplevel]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: /home/hituzi_no_sippo/workspace/my_projects/hooks_for_lefthook/reproduce/not_work_LEFTHOOK_QUIET

│ [lefthook] cmd: [git rev-parse --git-path hooks]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git/hooks

│ [lefthook] cmd: [git rev-parse --git-path info]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git/info

│ [lefthook] cmd: [git rev-parse --git-dir]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git

+ set +x
=========================================
version: 1.5.6 dce1a0b6e0e8e9dc38d5376dad15ce29a7f137a8
=========================================
+ ./lefthook_1.5.6 install
│ [lefthook] cmd: [git rev-parse --show-toplevel]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: /home/hituzi_no_sippo/workspace/my_projects/hooks_for_lefthook/reproduce/not_work_LEFTHOOK_QUIET

│ [lefthook] cmd: [git rev-parse --git-path hooks]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git/hooks

│ [lefthook] cmd: [git rev-parse --git-path info]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git/info

│ [lefthook] cmd: [git rev-parse --git-dir]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git

│ Searching config in:/home/hituzi_no_sippo/workspace/my_projects/hooks_for_lefthook/reproduce/not_work_LEFTHOOK_QUIET
sync hooks: ✔️ (foo)
+ ./lefthook_1.5.6 run foo
│ [lefthook] cmd: [git rev-parse --show-toplevel]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: /home/hituzi_no_sippo/workspace/my_projects/hooks_for_lefthook/reproduce/not_work_LEFTHOOK_QUIET

│ [lefthook] cmd: [git rev-parse --git-path hooks]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git/hooks

│ [lefthook] cmd: [git rev-parse --git-path info]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git/info

│ [lefthook] cmd: [git rev-parse --git-dir]
│ [lefthook] dir:
│ [lefthook] err: <nil>
│ [lefthook] out: .git

╭───────────────────────────────╮
│ 🥊 lefthook v1.5.6  hook: foo │
╰───────────────────────────────╯
┃  bar ❯

Hello World


  ────────────────────────────────────
summary: (done in 0.00 seconds)
✔️  bar
+ set +x
$
```


Discussion / hints:

Fix patch:
diff --git a/internal/log/skip_settings.go b/internal/log/skip_settings.go
index 47aa1fab..2e9cb551 100644
--- a/internal/log/skip_settings.go
+++ b/internal/log/skip_settings.go
@@ -27,10 +27,11 @@ func (s *SkipSettings) ApplySettings(tags string, skipOutput interface{}) {
 		for _, skipOption := range typedSkipOutput {
 			s.applySetting(skipOption.(string))
 		}
-		if tags != "" {
-			for _, skipOption := range strings.Split(tags, ",") {
-				s.applySetting(skipOption)
-			}
+	}
+
+	if tags != "" {
+		for _, skipOption := range strings.Split(tags, ",") {
+			s.applySetting(skipOption)
 		}
 	}
 }


Test patch:
diff --git a/internal/log/skip_settings_test.go b/internal/log/skip_settings_test.go
index 15706964..f2f85e9f 100644
--- a/internal/log/skip_settings_test.go
+++ b/internal/log/skip_settings_test.go
@@ -7,18 +7,22 @@ import (
 
 func TestSkipSetting(t *testing.T) {
 	for i, tt := range [...]struct {
+		tags     string
 		settings interface{}
 		results  map[string]bool
 	}{
 		{
+			tags:     "",
 			settings: []interface{}{},
 			results:  map[string]bool{},
 		},
 		{
+			tags:     "",
 			settings: false,
 			results:  map[string]bool{},
 		},
 		{
+			tags:     "",
 			settings: []interface{}{"failure", "execution"},
 			results: map[string]bool{
 				"failure":   true,
@@ -26,6 +30,7 @@ func TestSkipSetting(t *testing.T) {
 			},
 		},
 		{
+			tags: "",
 			settings: []interface{}{
 				"meta",
 				"summary",
@@ -50,6 +55,7 @@ func TestSkipSetting(t *testing.T) {
 			},
 		},
 		{
+			tags:     "",
 			settings: true,
 			results: map[string]bool{
 				"meta":           true,
@@ -63,11 +69,26 @@ func TestSkipSetting(t *testing.T) {
 				"empty_summary":  true,
 			},
 		},
+		{
+			tags:     "meta,summary,success,skips,empty_summary",
+			settings: nil,
+			results: map[string]bool{
+				"meta":           true,
+				"summary":        true,
+				"success":        true,
+				"failure":        false,
+				"skips":          true,
+				"execution":      false,
+				"execution_out":  false,
+				"execution_info": false,
+				"empty_summary":  true,
+			},
+		},
 	} {
 		t.Run(fmt.Sprintf("%d", i), func(t *testing.T) {
 			var settings SkipSettings
 
-			(&settings).ApplySettings("", tt.settings)
+			(&settings).ApplySettings(tt.tags, tt.settings)
 
 			if settings.SkipMeta() != tt.results["meta"] {
 				t.Errorf("expected SkipMeta to be %v", tt.results["meta"])