Skip to content

Commit

Permalink
Merge pull request #259 from broadinstitute/sy-whitespace-cleanup
Browse files Browse the repository at this point in the history
Add autopep8 pre-commit hook.
  • Loading branch information
tomkinsc authored Jul 27, 2016
2 parents 29ee687 + aa2c211 commit aadf7ef
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions contrib/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

status=0
touched_python_files=$(git diff --cached --name-only | grep -E '\.py$')
if [ -n "$touched_python_files" ]; then
options="\
--aggressive \
--exclude='tools/build/*' \
--select=W291,W293 \
--max-line-length=120 \
"

output=$(autopep8 -d $options "${touched_python_files[@]}")
status=$?

if [ -n "$output" ]; then
autopep8 -i -j 0 $options "${touched_python_files[@]}"
echo ">>> autopep8 edited some files <<<"
exit 1
fi
fi

exit $status

0 comments on commit aadf7ef

Please sign in to comment.