Last active
September 4, 2015 16:55
-
-
Save beck/0119ee3a6bf280a60321 to your computer and use it in GitHub Desktop.
git util to isort all files with a diff
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 | |
# | |
# git isort - isort files with a diff | |
# | |
# to use: | |
# * install isort (this code uses pyenv and has isort installed in 2.7.5) | |
# * place this file anywhere on PATH, callable via `git isort` | |
# | |
isort_cmd=$(pyenv root)/versions/2.7.5/bin/isort | |
$isort_cmd --version >/dev/null 2>&1 | |
if [ $? != 0 ] | |
then | |
echo "isort is broken" | |
exit | |
fi | |
for f in $(git diff head --name-only) | |
do | |
echo "isort $f" | |
$isort_cmd "$f" | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment