Skip to content

Instantly share code, notes, and snippets.

@anboo
Created May 23, 2020 18:00
Show Gist options
  • Save anboo/2e3fed005e2af3403072b6ab57627bc4 to your computer and use it in GitHub Desktop.
Save anboo/2e3fed005e2af3403072b6ab57627bc4 to your computer and use it in GitHub Desktop.
#!/bin/bash
echoerr() { echo -e "\e[1;31m$@\e[0m" 1>&2; }
git diff --diff-filter=MAT --name-only --cached | while read line;
do
filename=$(tempfile)$(echo $line | sed 's/\//_/g');
git show :$line > $filename;
if ! eval 'phpcs --standard=./vendor/escapestudios/symfony2-coding-standard/Symfony2 --extensions=php --ignore=Tests $filename > /dev/null'; then
if eval 'phpcs --standard=./vendor/escapestudios/symfony2-coding-standard/Symfony2 --extensions=php --ignore=Tests $line > /dev/null'; then
echoerr "!!!!ВНИМАНИЕ!!!!";
echoerr "Кажется вы забыли сделать git add $line после того как сделали fix кодинг стайла, посмотрите git status:";
git status;
else
#print more information about cs
phpcs --standard=./vendor/escapestudios/symfony2-coding-standard/Symfony2 --extensions=php --ignore=Tests $line
fi;
exit 1;
fi;
rm $filename;
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment