浏览代码

Hooks: Use pygmentize if available to visualize diff

Rémi Verschelde 5 年之前
父节点
当前提交
4d52761da6
共有 2 个文件被更改,包括 12 次插入4 次删除
  1. 6 2
      misc/hooks/pre-commit-black
  2. 6 2
      misc/hooks/pre-commit-clang-format

+ 6 - 2
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.

+ 6 - 2
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.