Created
August 25, 2012 02:32
-
-
Save eddyxu/3459054 to your computer and use it in GitHub Desktop.
Git pre-commit script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# | |
# Git Precommit Script for Research project. | |
# Lei Xu <eddyxu@gmail.com> | |
# Enforce C++ Style Checking (Google C++ Style). | |
# Note: you must have cpplint.py installed in your $PATH | |
CPPFILES=`git diff --cached --name-only | grep -E '^.+\.(h|hpp|cpp|cc)$'` | |
if [ ! -z "$CPPFILES" ]; then | |
echo "$CPPFILES" | xargs -n 128 cpplint.py | |
[ $? -gt 0 ] && exit 1 | |
fi | |
# Enforce Python Style Checking (PEP8) | |
# http://www.python.org/dev/peps/pep-0008/ | |
# Note: must have pep8 installed in $PATH. | |
PYFILES=`git diff --cached --name-only | grep -E '^.+\.py$'` | |
if [ ! -z "$PYFILES" ]; then | |
# TODO: add pylint check someday? | |
echo "$PYFILES" | xargs -n 128 pep8 | |
[ $? -gt 0 ] && exit 1 | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment