Skip to content

Instantly share code, notes, and snippets.

@openrijal
Created August 19, 2016 10:42
Show Gist options
  • Save openrijal/62a3a187c39751b3cf6d2c976d3ccca4 to your computer and use it in GitHub Desktop.
Save openrijal/62a3a187c39751b3cf6d2c976d3ccca4 to your computer and use it in GitHub Desktop.
shell script to run pyflakes on all python files in a git diff
#!/bin/bash
PYFLAKES=$(which pyflakes)
GIT=$(which git)
BRANCH=$($GIT rev-parse --abbrev-ref HEAD)
if [ $# -eq 0 ]
then
echo "No arguments supplied, please provide atleast 1 branch or commit hash. SYNTAX: difflakes [src] [dst]"
exit;
fi
if [ "$1" != "master" ]; then
A=$1
else
A='master'
fi
if [ -z "$2" ]; then
B=$BRANCH
else
B=$2
fi
echo "running pyflakes on diff between $A and $B"
pyflakes $(git diff $A..$B --name-only | grep \.py$)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment