Skip to content

Instantly share code, notes, and snippets.

@peregrinogris
Last active August 29, 2015 14:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peregrinogris/ef05f71f3d102d4626b1 to your computer and use it in GitHub Desktop.
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')
#!/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
@peregrinogris
Copy link
Author

Install under /usr/local/bin/git-lint
Pep8 Error Codes: http://pep8.readthedocs.org/en/latest/intro.html#error-codes

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment