Created
November 29, 2013 09:28
-
-
Save umurkontaci/7703411 to your computer and use it in GitHub Desktop.
Get the list of PEP8 errors you have introduced. Ignores "E501 Line too long" and "W293 Whitespace in empty line". This be changed from IGNORED_RULES value. Checkout the repository you want to check and call `pep8_introduced.sh master` (replace master with the target branch)
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 | |
CURRENT_BRANCH=`git branch --no-color | grep '*' | sed s/\*\ //` | |
TARGET_BRANCH=$1 | |
CHANGED_FILE_LIST=filelist.diff.tmp | |
TARGET_PEP8="$TARGET_BRANCH".pep8.tmp | |
CURRENT_PEP8="$CURRENT_BRANCH".pep8.tmp | |
IGNORED_RULES="E501,W293" | |
if [[ -z "$1" ]]; then | |
echo 'Usage: ./pep_introduced.sh target_branch' | |
echo | |
else | |
exec 7<&2 | |
exec 2<&- | |
git checkout $TARGET_BRANCH | |
git diff --name-only "$TARGET_BRANCH".."$CURRENT_BRANCH" | grep .py > $CHANGED_FILE_LIST | |
echo > $TARGET_PEP8 | |
echo > $CURRENT_PEP8 | |
while read line | |
do | |
pep8 --ignore $IGNORED_RULES $line >> $TARGET_PEP8 | |
done < $CHANGED_FILE_LIST | |
git checkout $CURRENT_BRANCH | |
while read line | |
do | |
pep8 --ignore $IGNORED_RULES $line >> $CURRENT_PEP8 | |
done < $CHANGED_FILE_LIST | |
exec 2<&7 | |
exec 7<&- | |
diff $TARGET_PEP8 $CURRENT_PEP8 | grep '^>' | sed s/^\>\ // | |
rm $TARGET_PEP8 | |
rm $CURRENT_PEP8 | |
rm $CHANGED_FILE_LIST | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment