Skip to content

Instantly share code, notes, and snippets.

@millerdev
Last active September 15, 2020 05:38
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 millerdev/e25014e4b886a5c619419d56b778a423 to your computer and use it in GitHub Desktop.
Save millerdev/e25014e4b886a5c619419d56b778a423 to your computer and use it in GitHub Desktop.
Run fake8 on lines changed in current branch
#! /bin/bash
# https://gist.github.com/millerdev/e25014e4b886a5c619419d56b778a423
#
# Usage: git flake8 [refname] [flake8 options]
if [ "${1:0:1}" = "-" ]; then
BRANCH=origin/master
else
BRANCH=${1:-origin/master}
shift
fi
CURRENT=$(git rev-parse --abbrev-ref HEAD)
echo "$BRANCH...$CURRENT"
git diff $BRANCH...$CURRENT | flake8 --diff "$@" 1>&2
@millerdev
Copy link
Author

Copy this script to a directory in $PATH and make the file executable (chmod +x git-flake8). flake8 must be installed and accessible via $PATH as well (a virtualenv is a great place to put that).

@sravfeyn
Copy link

Thanks Daniel!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment