Skip to content

Instantly share code, notes, and snippets.

@trq
Created September 28, 2013 13:21
Show Gist options
  • Save trq/6742011 to your computer and use it in GitHub Desktop.
Save trq/6742011 to your computer and use it in GitHub Desktop.
php lint git-hook
#!/bin/bash
git diff --cached --name-status --diff-filter=ACMR | while read STATUS FILE; do
if [[ "$FILE" =~ ^.+(php|inc)$ ]]; then
php -l "$FILE" 1> /dev/null
if [ $? -ne 0 ]; then
echo "Aborting commit due to files with syntax errors" >&2
exit 1
fi
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment