Last active
August 29, 2015 14:05
-
-
Save peregrinogris/ef05f71f3d102d4626b1 to your computer and use it in GitHub Desktop.
Run pylint and pep8 linters on all changed and added python files, or in the current branch (by passing 'fbranch')
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
#!/usr/bin/env bash | |
branch=`git branch | grep '*' | awk '{print $2}'` | |
get_files() { | |
if test "$1" = "fbranch"; then | |
echo `git diff develop..$branch --name-status | egrep '[AM]\t' | awk '{print $2}' | grep '.py'` | |
else | |
echo `git status --porcelain | egrep '[AM] ' | awk '{print $2}' | grep '.py'` | |
fi | |
} | |
files=`get_files $1` | |
while getopts ":f" opt; do | |
case $opt in | |
f) | |
echo -e '\n\n\033[0;32mPylint ----------------------------------------------\033[0m' | |
files=`get_files $2` | |
pylint -r n -f colorized -d line-too-long -d too-many-locals $files | |
;; | |
\?) | |
echo "Invalid option: -$OPTARG" >&2 | |
;; | |
esac | |
done | |
echo -e '\n\n\033[0;32mPEP8 ------------------------------------------------\033[0m' | |
pep8 --ignore E501,E711,E712,E122,E123,E128 $files |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Install under
/usr/local/bin/git-lint
Pep8 Error Codes: http://pep8.readthedocs.org/en/latest/intro.html#error-codes