From 8280fc9b57754b9aff9500b8bd39b0becfc22e7e Mon Sep 17 00:00:00 2001 From: Heiko Wolf <heiko.wolf@uni-leipzig.de> Date: Wed, 8 Dec 2021 08:53:03 +0100 Subject: [PATCH] actual install script code style check --- install-codestylechecker.sh | 78 +++++++++++++++++++++++++++++-------- 1 file changed, 62 insertions(+), 16 deletions(-) diff --git a/install-codestylechecker.sh b/install-codestylechecker.sh index 55eb621e6f1..02c158a41de 100755 --- a/install-codestylechecker.sh +++ b/install-codestylechecker.sh @@ -4,41 +4,87 @@ red="\e[0;91m" green="\e[0;92m" clean="\e[0m" +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 if [ $(which curl) != "/usr/bin/curl" ] then - echo -e "\n${red}Benötigt curl.\n" exit 1 fi +gitdir=$(pwd) + reset -gitdir=$(pwd) +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 + + chmod +x $HOME/bin/codestylechecker/phpcs.phar + + 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" + exit 0 + + elif [ $1 = "update" ] + then -echo -e "${green}Installiere Codestylechecker...${clean}\n" + echo -e "\n${green}Update...${clean}\n" -mkdir -p $HOME/bin/codestylechecker + cd $HOME/bin/codestylechecker -cd $HOME/bin/codestylechecker + curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar -curl -OL https://squizlabs.github.io/PHP_CodeSniffer/phpcs.phar -curl -OL https://alpha.finc.info/vufind2/logs/alpha/CodeSniffer.conf + chmod +x $HOME/bin/codestylechecker/phpcs.phar -chmod +x $HOME/bin/codestylechecker/phpcs.phar + cd $gitdir/.git/hooks/ -echo -e "\n${green}Kopiere Hooks nach ${gitdir}/.git/hooks\n${clean}" + mv pre-commit pre-commit.old.$(date +%Y-%m-%d) + mv pre-push pre-push.old.$(date +%Y-%m-%d) -cd $gitdir/.git/hooks/ + curl -OL https://alpha.finc.info/vufind2/logs/alpha/pre-commit + curl -OL https://alpha.finc.info/vufind2/logs/alpha/pre-push -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 -chmod +x $gitdir/.git/hooks/pre-commit -chmod +x $gitdir/.git/hooks/pre-push + echo -e "\n${green}Ready.${clean}\n" + exit 0 + fi -echo -e "\n${green}Fertig!${clean}\n" +echo -e "\n${red}Nix ist passiert.${clean}\n" -exit 0 +exit 1 #heiko.wolf@uni-leipzig.de, 2021 -- GitLab