Last active
September 13, 2015 00:59
-
-
Save matthieuprat/a9ee3c56d8677bead02e to your computer and use it in GitHub Desktop.
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 | |
while read -r f | |
do | |
if $(git diff-files --quiet -- ":(literal)$f") | |
then | |
# Check the file in the worktree since there are no unstaged changes. | |
flake8 "$f" || err=1 | |
else | |
# Pipe staged changes to flake8 and replace 'stdin:<error>' with | |
# '<filename>(staged):<error>'. | |
git cat-file -p ":$f" | flake8 - | sed "s|^stdin|${f/|/\\|}(staged)|" | |
[ "${PIPESTATUS[1]}" = "0" ] || err=1 | |
fi | |
done < <(git diff-index --diff-filter=AM --cached --name-only HEAD -- \*.py) | |
exit ${err-0} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment