Simple Perl Pre-commit Hook for git
This seems to work:
#!/bin/sh exec 2>&1 # <URL:http://stackoverflow.com/questions/2412450/git-pre-commit-hook-changed-added-files> # Find Perl files and compile them to test for valid syntax git diff --cached --name-status -- *.pl *.pm | while read status file; do # Skip files that are going away if [ "XD" = "X$status" ]; then continue fi if ! perl -c $file; then exit 111 fi done
Save this script as .git/hooks/pre-commit and you should prevent yourself from checking in any Perl script or module that doesn't pass the "perl -c" compile test.
No comments:
Post a Comment