Running perltidy in a Git commit hook (githook-perltidy)

I have found a couple of attempts at integrating perltidy into Git commit hooks, but nothing yet that I considered robust enough. The scripts ignore the state of the index, modify the working tree, and then forget to update the index before the commit. They didn't recover from a failed tidy run, leaving both the working tree and index messed up. Critically for me I could not do an interactive or patched "git add" and have the final commit reflect what I wanted.

githook-perltidy is my answer to this challenge. Robustness is achieved by stashing the working tree and index before the tidy run, which is re-applied on error. The same stash can be applied on top of the new commit (using a post-commit hook) to merge non-indexed working tree changes afterwards. The POD inside the script hopefully documents the process in sufficient detail to give you confidence in the method. Code has the final say of course...

You can grab a tar or zip file of the distribution now from the github repository at Feedback (and patches for tests!) is welcome.


Thank you about your informations
I have used Github . Now I will applicated this for me

Leave a comment

About Mark Lawrence

user-pic I blog about Perl.