Skip to content

Instantly share code, notes, and snippets.

@dmj
Created September 25, 2012 05:42
Show Gist options
  • Save dmj/3780185 to your computer and use it in GitHub Desktop.
Save dmj/3780185 to your computer and use it in GitHub Desktop.
Git pre-commit, check coding style
#!/bin/zsh
### $Id:$
###
### Pre-commit hook for VuFind2
###
### Based on Z-Shell, maybe portable bash or sh.
###
### $Log:$
###
error=0
## Stash all unstaged changes
git stash -q --keep-index
for FILE in `git diff --cached --name-only | grep ".php$"`
do
## Check coding style
phpcs --standard=PEAR $FILE
let "error=$error || $?"
done
## Unstash unstaged
git stash pop -q
exit $error
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment