diff --git a/.gitignore b/.gitignore index c2021816..78c61ff1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,8 @@ *.egg-info *.py[co] +*.pytest_cache /.coverage /.tox +/build /dist .vscode/ diff --git a/pre_commit/commands/run.py b/pre_commit/commands/run.py index 2a08dff0..44a7aa4c 100644 --- a/pre_commit/commands/run.py +++ b/pre_commit/commands/run.py @@ -222,6 +222,13 @@ def _run_single_hook( if retcode: _subtle_line(f'- exit code: {retcode}', use_color) + if verbose and hook.description: + if '\n' in hook.description: + _subtle_line('- description: |', use_color) + for l in hook.description.splitlines(): + _subtle_line(' ' + l, use_color) + else: + _subtle_line(f'- description: {hook.description}', use_color) # Print a message if failing due to file modifications if files_modified: diff --git a/testing/resources/failing_hook_repo/.pre-commit-hooks.yaml b/testing/resources/failing_hook_repo/.pre-commit-hooks.yaml index 118cc8b1..e74f7b48 100644 --- a/testing/resources/failing_hook_repo/.pre-commit-hooks.yaml +++ b/testing/resources/failing_hook_repo/.pre-commit-hooks.yaml @@ -1,5 +1,8 @@ - id: failing_hook name: Failing hook + description: | + Failing Hook Description + Longer description. entry: bin/hook.sh language: script files: . diff --git a/tests/commands/run_test.py b/tests/commands/run_test.py index 50a20f37..bbf9773c 100644 --- a/tests/commands/run_test.py +++ b/tests/commands/run_test.py @@ -173,6 +173,26 @@ def test_run_all_hooks_failing(cap_out, store, repo_with_failing_hook): ) +def test_run_all_hooks_failing_verbose(cap_out, store, repo_with_failing_hook): + _test_run( + cap_out, + store, + repo_with_failing_hook, + {'verbose': True}, + ( + b'Failing hook', + b'Failed', + b'hook id: failing_hook', + b'description: |', + b' Failing Hook Description', + b' Longer description.', + b'Fail\nfoo.py\n', + ), + expected_ret=1, + stage=True, + ) + + def test_arbitrary_bytes_hook(cap_out, store, tempdir_factory): git_path = make_consuming_repo(tempdir_factory, 'arbitrary_bytes_repo') with cwd(git_path):