Print git-diff when pre-commit fails 24/64224/1
authorThanh Ha <zxiiro@gmail.com>
Sat, 6 Jun 2020 14:01:53 +0000 (10:01 -0400)
committerThanh Ha <zxiiro@gmail.com>
Sat, 6 Jun 2020 14:02:05 +0000 (10:02 -0400)
When pre-commit fails and automatically fixes issues for us in Jenkins
we are not able to see what pre-commit automatically fixed. Adding
--show-diff-on-failure makes pre-commit perform a git-diff immediately
after failing to ensure more useful output is printed to inform the
contributor what changes are needed to pass the check.

Signed-off-by: Thanh Ha <zxiiro@gmail.com>
Change-Id: Ic2ad49fd6222bee0341c4826e6ccc463d05fda5f

tox.ini

diff --git a/tox.ini b/tox.ini
index 5f647f2..4c45861 100644 (file)
--- a/tox.ini
+++ b/tox.ini
@@ -21,7 +21,7 @@ commands = sphinx-build -W -b linkcheck -d {envtmpdir}/doctrees ./docs/ {toxinid
 basepython = python3
 deps = pre-commit
 commands =
-    pre-commit run --all-files
+    pre-commit run --all-files --show-diff-on-failure
     pre-commit run gitlint --hook-stage commit-msg --commit-msg-filename .git/COMMIT_EDITMSG
 
 [testenv:reno]