Skip to content

Commit

Permalink
fix #602: add GIT pre-commit hook
Browse files Browse the repository at this point in the history
  • Loading branch information
giampaolo committed Mar 4, 2015
1 parent 71bf18d commit 012dab5
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
1 change: 1 addition & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Bug tracker at https://github.com/giampaolo/psutil/issues
- #594: all deprecated APIs were removed.
- #599: [Windows] process name() can now be determined for all processes even
when running as a limited user.
- #602: pre-commit GIT hook.

**Bug fixes**

Expand Down
22 changes: 22 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,25 @@ upload-doc:
git-tag-release:
git tag -a release-`python -c "import setup; print(setup.get_version())"` -m `git rev-list HEAD --count`:`git rev-parse --short HEAD`
echo "done; now run 'git push --follow-tags' to push the new tag on the remote repo"

define GIT_PRE_COMMIT_HOOK
#!/bin/bash
pdb=`git diff --cached --name-only | grep -E '\.py$$' | xargs grep -n -H -E '(pdb\.set_trace\(\))'`
if [ ! -z "$$pdb" ] ; then
echo "commit aborted: you forgot a pdb in your python code"
echo $$pdb
exit 1
fi
flake8=`git diff --cached --name-only | grep -E '\.py$$' | xargs -r flake8`
if [ ! -z "$$flake8" ] ; then
echo "commit aborted: python code is not flake8-compliant"
echo $$flake8
exit 1
fi
endef
export GIT_PRE_COMMIT_HOOK

# install GIT pre-commit hooks
install-git-hooks:
echo "$$GIT_PRE_COMMIT_HOOK" > .git/hooks/pre-commit
chmod +x .git/hooks/pre-commit

0 comments on commit 012dab5

Please sign in to comment.