summaryrefslogtreecommitdiff
path: root/misc/hooks
diff options
context:
space:
mode:
authorRémi Verschelde <rverschelde@gmail.com>2020-03-30 09:03:38 +0200
committerRémi Verschelde <rverschelde@gmail.com>2020-03-30 09:05:59 +0200
commit4d52761da6f15ee0374a4cac958cc7cd12507adc (patch)
tree98d19227079e81da8a13d1a0b326452ff11c122f /misc/hooks
parent164826a39bca2fb7b7277752cbc1df8833ce0f1a (diff)
Hooks: Use pygmentize if available to visualize diff
Diffstat (limited to 'misc/hooks')
-rwxr-xr-xmisc/hooks/pre-commit-black8
-rwxr-xr-xmisc/hooks/pre-commit-clang-format8
2 files changed, 12 insertions, 4 deletions
diff --git a/misc/hooks/pre-commit-black b/misc/hooks/pre-commit-black
index 3dd0a13330..2dcc2e8cf1 100755
--- a/misc/hooks/pre-commit-black
+++ b/misc/hooks/pre-commit-black
@@ -18,8 +18,12 @@ FILE_EXTS="py"
# Use pygmentize instead of cat to parse diff with highlighting.
# Install it with `pip install pygments` (Linux) or `easy_install Pygments` (Mac)
-# READER="pygmentize -l diff"
-READER=cat
+PYGMENTIZE=`which pygmentize`
+if [ ! -z "$PYGMENTIZE" ]; then
+ READER="pygmentize -l diff"
+else
+ READER=cat
+fi
##################################################################
# There should be no need to change anything below this line.
diff --git a/misc/hooks/pre-commit-clang-format b/misc/hooks/pre-commit-clang-format
index f3689890df..c5cf4ecbb1 100755
--- a/misc/hooks/pre-commit-clang-format
+++ b/misc/hooks/pre-commit-clang-format
@@ -31,8 +31,12 @@ FILE_EXTS=".c .h .cpp .hpp .cc .hh .cxx .m .mm .inc .java .glsl"
# Use pygmentize instead of cat to parse diff with highlighting.
# Install it with `pip install pygments` (Linux) or `easy_install Pygments` (Mac)
-# READER="pygmentize -l diff"
-READER=cat
+PYGMENTIZE=`which pygmentize`
+if [ ! -z "$PYGMENTIZE" ]; then
+ READER="pygmentize -l diff"
+else
+ READER=cat
+fi
##################################################################
# There should be no need to change anything below this line.