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 https://github.com/mlawren/githook-perltidy. Feedback (and patches for tests!) is welcome.
Thank you about your informations
I have used Github . Now I will applicated this for me
Since this initial announcement went out I've written some tests for githook-perltidy and discovered a couple of issues. Namely that the script wasn't doing what it claimed to do.
Version 0.02 was pushed to Github a few minutes ago with some important fixes. For anyone who downloaded githook-perltidy before I wrote this comment please do so again. My apologies for the early release.