- 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 .gitmv hooks hooks.pygithooks.bakln -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 1to 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
incrementalflag. (Does nothing ifincrementalis 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).
pygithooksis released under the BSD license.reindent.pyis bundled for ease of installation; it is in the public domain. See the top ofhooks/reindent.pyfor details.pep8.pyis included as a submodule. It is under the expat license. See the top ofhooks/pep8/pep8.pyfor details.