mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
Add a --show-diff-on-failure option
This commit is contained in:
parent
0ece39c484
commit
05c88738b0
3 changed files with 32 additions and 1 deletions
|
|
@ -3,6 +3,7 @@ from __future__ import unicode_literals
|
|||
|
||||
import logging
|
||||
import os
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
from pre_commit import color
|
||||
|
|
@ -152,6 +153,13 @@ def _run_hooks(repo_hooks, args, environ):
|
|||
retval = 0
|
||||
for repo, hook in repo_hooks:
|
||||
retval |= _run_single_hook(hook, repo, args, skips, cols)
|
||||
if (
|
||||
retval and
|
||||
args.show_diff_on_failure and
|
||||
subprocess.call(('git', 'diff', '--quiet')) != 0
|
||||
):
|
||||
print('All changes made by hooks:')
|
||||
subprocess.call(('git', 'diff'))
|
||||
return retval
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue