Skip to content

Instantly share code, notes, and snippets.

@ANtlord
Created October 12, 2017 12:20
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 ANtlord/8602f3653ea42d8b34ed656671daa88e to your computer and use it in GitHub Desktop.
Save ANtlord/8602f3653ea42d8b34ed656671daa88e to your computer and use it in GitHub Desktop.
#!/bin/bash
#COMMAND='/usr/local/bin/flake8 --config=/etc/flake8/.flake8'
COMMAND='/home/antlord/.pyenv/shims/python -m flake8 --config=/media/storage/develop/h4r-platform/.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.
${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