Skip to content

Instantly share code, notes, and snippets.

@jsenin
Created April 21, 2016 16:49
Show Gist options
  • Save jsenin/d126e95375345633ac69bca90e88e089 to your computer and use it in GitHub Desktop.
Save jsenin/d126e95375345633ac69bca90e88e089 to your computer and use it in GitHub Desktop.
#!/bin/bash
# file: .git/hooks/pre-commit
#
# phpcs needed
# apt-get install php-codesniffer
while read -r file;
do
file=${file:2}
if [[ $file = *.php ]];
then
phpcs --standard=psr2 "$file"
if [ $? -ne 0 ]; then
echo "PSR2 not passed"
exit 1 ;
fi;
fi
done < <(git diff --cached --name-status --diff-filter=ACM)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment