Created
July 26, 2016 06:43
-
-
Save tossmilestone/a8bc2b814f75cde34cb77ea2d47db07b to your computer and use it in GitHub Desktop.
Git push pep8 check
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/bash | |
COMMAND='flake8' | |
TEMPDIR=`mktemp -d` | |
while read oldrev newrev refname; do | |
files=`git diff --name-only ${oldrev} ${newrev}` | |
for file in ${files}; do | |
object=`git ls-tree --full-name -r ${newrev} | egrep "(\s)${file}\$" | awk '{ print $3 }'` | |
if [ -z ${object} ]; then continue; fi | |
mkdir -p "${TEMPDIR}/`dirname ${file}`" &> /dev/null | |
git cat-file blob ${object} > ${TEMPDIR}/${file} | |
done; | |
done | |
# Change the filename here if your flake8 configuration | |
# has a different name. | |
git show HEAD:tox.ini > ${TEMPDIR}/tox.ini | |
${COMMAND} ${TEMPDIR} | |
STATUS=$? | |
rm -rf ${TEMPDIR} &> /dev/null | |
echo status $STATUS | |
exit ${STATUS} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment