Skip to content

Instantly share code, notes, and snippets.

@notmatthancock
Created August 31, 2020 20:43
Show Gist options
  • Save notmatthancock/ee81a5855b48c98699cbf7fe1df9fd82 to your computer and use it in GitHub Desktop.
Save notmatthancock/ee81a5855b48c98699cbf7fe1df9fd82 to your computer and use it in GitHub Desktop.
# Run flake8 only on new files according to git-diff
#
# If run with no arguments, i.e.,
# $ dflake8
# then the diff is taken against the master branch.
# If run with a single argument, then that argument is used for diff'ing, i.e.,
# $ dflake8 feature-branch
# or
# $ dflake8 HEAD
dflake8 () {
if [ -n "$1" ]
then
commit=$1
else
commit=master
fi
echo Using \"$commit\" as base for \'diff\'
git diff --name-only --diff-filter=AM $commit '***.py' \
| xargs --no-run-if-empty -t flake8
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment