From d58d3873e8eef831a2e7cc95cc88e33d5f5e62e9 Mon Sep 17 00:00:00 2001 From: Igor Rzegocki Date: Fri, 12 Jun 2020 21:44:59 +0200 Subject: [PATCH] Fix `YamlLint` hook. Previously, when yamllint was failing, the exit code of the tool was reflecting that. However, recently yamllint introduced `--strict` parameter to do that. Without, it always returns success no matter if lints were successful or failed. Which caused false-positives in ovecommit, which was thinking that everything is okay. This fix adds `--strict` to `yamllint` invocation, to bring back proper behavior, and force hook to fail, when the tool fails. --- CHANGELOG.md | 4 ++++ config/default.yml | 2 +- spec/overcommit/hook/pre_commit/yaml_lint_spec.rb | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1711cb54..9978dd90 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Overcommit Changelog +## master + +* Fix `YamlLint` pre-commit hook + ## 0.53.0 * Improve performance in `PhpCs` pre-commit hook diff --git a/config/default.yml b/config/default.yml index 74503e8e..b31e1f06 100644 --- a/config/default.yml +++ b/config/default.yml @@ -885,7 +885,7 @@ PreCommit: enabled: false description: 'Analyze with YAMLlint' required_executable: 'yamllint' - flags: ['--format=parsable'] + flags: ['--format=parsable', '--strict'] install_command: 'pip install yamllint' include: - '**/*.yaml' diff --git a/spec/overcommit/hook/pre_commit/yaml_lint_spec.rb b/spec/overcommit/hook/pre_commit/yaml_lint_spec.rb index 72ebc6e8..cb08f4e1 100644 --- a/spec/overcommit/hook/pre_commit/yaml_lint_spec.rb +++ b/spec/overcommit/hook/pre_commit/yaml_lint_spec.rb @@ -19,7 +19,7 @@ end before do - subject.stub(:execute).with(%w[yamllint --format=parsable], args: applicable_files). + subject.stub(:execute).with(%w[yamllint --format=parsable --strict], args: applicable_files). and_return(result) end