Newer
Older

Heiko Wolf
committed
#!/bin/bash
red="\e[0;91m"
green="\e[0;92m"
clean="\e[0m"
Robert Lange
committed
if [ -z $1 ]
then
echo -e "\n${red}Nicht genau angegeben was ich tun soll.${clean}\n"
echo -e "---------------------------------------------------------------------------"
echo -e "\n ./install-codestylechecker.sh install - install the checker and hooks\n"
echo -e "\n ./install-codestylechecker.sh update - update the checker and hooks\n"
echo -e "--------------------------------------------------------------------------\n"
exit 1
fi

Heiko Wolf
committed
Robert Lange
committed
if [ $(which curl) != "/usr/bin/curl" ]

Heiko Wolf
committed
then
echo -e "\n${red}Benötigt curl.\n"
exit 1

Heiko Wolf
committed

Heiko Wolf
committed
reset
if [ $1 = "install" ]
then
gitdir=$(pwd)
echo -e "${green}Install...${clean}\n"
mkdir -p $HOME/bin/codestylechecker
cd $HOME/bin/codestylechecker
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar
curl -OL https://alpha.finc.info/vufind2/logs/alpha/CodeSniffer.conf
Robert Lange
committed
curl -OL https://alpha.finc.info/vufind2/logs/alpha/diffFilter.phar
curl -OL https://alpha.finc.info/vufind2/logs/alpha/php-cs-fixer3
chmod +x $HOME/bin/codestylechecker/phpcs.phar
Robert Lange
committed
chmod +x $HOME/bin/codestylechecker/diffFilter.phar
chmod +x $HOME/bin/codestylechecker/php-cs-fixer3
echo -e "\n${green}Kopiere Hooks nach ${gitdir}/.git/hooks\n${clean}"
cd $gitdir/.git/hooks/
mv pre-commit pre-commit.old.$(date +%Y-%m-%d)
mv pre-push pre-push.old.$(date +%Y-%m-%d)
curl -OL https://alpha.finc.info/vufind2/logs/alpha/pre-commit
curl -OL https://alpha.finc.info/vufind2/logs/alpha/pre-push
chmod +x $gitdir/.git/hooks/pre-commit
chmod +x $gitdir/.git/hooks/pre-push
echo -e "\n${green}Ready${clean}\n"
Robert Lange
committed
echo -e "\n${green}Activate PHP CS Fixer in PHPSorm: https://projekte.ub.uni-leipzig.de/projects/finc-intern/wiki/Code-Quality-Checking_mit_PHPStorm${clean}\n"
exit 0
elif [ $1 = "update" ]
then

Heiko Wolf
committed
echo -e "\n${green}Update...${clean}\n"

Heiko Wolf
committed

Heiko Wolf
committed
curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar

Heiko Wolf
committed
chmod +x $HOME/bin/codestylechecker/phpcs.phar

Heiko Wolf
committed

Heiko Wolf
committed
mv pre-commit pre-commit.old.$(date +%Y-%m-%d)
mv pre-push pre-push.old.$(date +%Y-%m-%d)

Heiko Wolf
committed
curl -OL https://alpha.finc.info/vufind2/logs/alpha/pre-commit
curl -OL https://alpha.finc.info/vufind2/logs/alpha/pre-push

Heiko Wolf
committed
chmod +x $gitdir/.git/hooks/pre-commit
chmod +x $gitdir/.git/hooks/pre-push

Heiko Wolf
committed
echo -e "\n${green}Ready.${clean}\n"
exit 0
fi

Heiko Wolf
committed
echo -e "\n${red}Nix ist passiert.${clean}\n"

Heiko Wolf
committed

Heiko Wolf
committed
#heiko.wolf@uni-leipzig.de, 2021