Skip to content

Instantly share code, notes, and snippets.

@ssanderson
Created June 26, 2014 15:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssanderson/04aed4d45c8d6d34c091 to your computer and use it in GitHub Desktop.
Save ssanderson/04aed4d45c8d6d34c091 to your computer and use it in GitHub Desktop.
# Run flake8 against any added/modified python files in the current git repo.
function check8 ()
{
errors=`git diff --relative --name-only --diff-filter AM --ignore-submodules | grep -e "\.py" | xargs flake8`
retval=$?
# xargs returns 127 if flake8 couldn't be found
if [ "$retval" = "127" ]
then
echo "Failed to find flake8. Check your virtualenv?"
return 127
elif [ "$retval" != "0" ]
then
echo "Errors Found:"
echo "${errors}"
return "$retval"
else
echo "No errors found."
return 0
fi
# If errors is not empty
if [ ! -z "$errors" ]
then
echo "Errors Found:"
echo "a${errors}b"
return 1
else
echo "No errors found."
return 0
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment