- Requires Python 2.5+. Not tested with Py3k.
- Clone this repo & submodules:
git clone git://github.com/lumberlabs/pygithooks.git --recursive
- Configure as desired (see below).
- If this is the only git hook you are using:
cd <your_repo>
cd .git
mv hooks hooks.pygithooks.bak
ln -s /path/to/pygithooks/hooks hooks
- If you want to use these hooks along with other hooks, just add
/path/to/pygithooks/hooks/pre-commit.py || exit 1
to your existingpre-commit
.
Configuration works through git config
, in the section pygithooks
.
Sample configuration command:
git config --global pygithooks.pep8-ignore E501,E261,E302
Supported keys:
- check-pep8
- whether to run pep8.py at all; if set to false, only checks tabs and indentation.
- sample value:
false
- default value:
true
- pep8-ignore
- pep8 checks to skip, passed directly to pep8's --ignore
- sample value:
E501,E261,E302
- default value: none
- pep8-exclude
- regular expression for filenames to exclude from pep8 checks
- sample value:
.*/migrations/.*
- default value: none
- incremental
- in incremental mode, if a file failed the hooks before this commit, allow it through unchecked. This is useful in a large codebase that isn't already well-formatted: The hooks make sure that files never become badly formatted, but don't block development on existing badly formatted files.
- sample value:
true
- default value:
false
- incremental.verbose
- Print all filenames that were allowed through only because of the
incremental
flag. (Does nothing ifincremental
is not enabled.) This is useful for knowing which files should (eventually) be cleaned up. - sample value:
true
- default value:
false
- Print all filenames that were allowed through only because of the
- debug
- print some debug goo during processing. Handy for figuring out why pygithooks is not behaving as you expect. Don't leave this on. :)
- sample value:
true
- default value:
false
- Yes, please. Fork and send a pull request!
- Code formatting note: We ignore E501 (line too long).
pygithooks
is released under the BSD license.reindent.py
is bundled for ease of installation; it is in the public domain. See the top ofhooks/reindent.py
for details.pep8.py
is included as a submodule. It is under the expat license. See the top ofhooks/pep8/pep8.py
for details.