Git Hooks - pre-commit
leftnode.com
leftnode.com
I recently wrote a pre-commit hook that runs pylint on my Python files.
http://fitzgeraldnick.com/weblog/9/
“git diff –staged –name-only HEAD” will get you the files that are about to be committed and then you can check if they end with “.php” (or “.py” in my case) and go from there. I also check to see if “#!” and “python” are in the first line of a file because my pre-commit hook is written in python but doesn’t have an extension, just a crunch bang.
Did I miss something exciting here?
I figured it'd probably help someone out there, which is why I submitted it to HN.
I wrote up a bunch of different ones I used last year on a blog entry: http://benjamin-meyer.blogspot.com/2008/10/git-hooks.html
Think of it as the next level of unit testing. Have some bash scripts that you occasionally put an error in? add a bash -n hook on bash files to prevent mistakes. In the Arora repository there have been probably a dozen commits total that broke the build on one of the platforms. How many build breakage commits do you have in your repo?
Speaking of this, the ruby on rails guys seems to be really for tests, but to run a test (even the hello world return true one) takes several seconds... how do I improve this to take ms?