Last active
September 28, 2015 01:07
-
-
Save cbandy/1360674 to your computer and use it in GitHub Desktop.
git pre-commit hook
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/bin/sh | |
| # Run tools on files in the index | |
| git diff --cached --name-status \ | |
| | awk '$1 != "D" && $1 != "R" { $1 = ""; print }' \ | |
| | git checkout-index --stdin --temp \ | |
| | while read tmp orig | |
| do | |
| case $orig in | |
| *.php) | |
| lint=`php -l $tmp` || echo "$lint" | sed -e "s#$tmp#$orig#" | |
| phpcs --standard=Kohana --tab-width=4 $tmp \ | |
| | sed -e '1 { /^[[:blank:]]*$/ d; }' -e "/^FILE:/ s#$tmp#$orig#" | |
| ;; | |
| *) | |
| esac | |
| rm $tmp | |
| done \ | |
| | awk '{ print } END { exit FNR }' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment