Created
October 9, 2019 13:57
-
-
Save squizduos/327dfd12ef41ead0455eed5bf0bc37e8 to your computer and use it in GitHub Desktop.
Git diff code style fix and check: isort + autopep8 + flake8
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 | |
DIFF_FILES=$(git diff --name-only origin/master | grep '.*\.py') | |
if [ "$DIFF_FILES" ]; then | |
echo -e "Changed files:\n$DIFF_FILES\n" && DIFF=$(echo $DIFF_FILES | xargs) | |
isort &>/dev/null $DIFF && autopep8 --in-place --aggressive --aggressive $DIFF && flake8 $DIFF | |
[ $? -eq 0 ] && echo "Code quality check success" || echo "Code quality check failed" | |
else | |
echo -e "No changes detected" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment