diff --git a/Config/phpcs.xml b/Config/phpcs.xml index e430f8a..abe09b1 100644 --- a/Config/phpcs.xml +++ b/Config/phpcs.xml @@ -26,11 +26,11 @@ - + @@ -130,7 +130,6 @@ */tests/* - diff --git a/Hooks/default.sh b/Hooks/default.sh new file mode 100644 index 0000000..6614038 --- /dev/null +++ b/Hooks/default.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +strindex() { + x="${1%%$2*}" + [[ "$x" = "$1" ]] && echo -1 || echo "${#x}" +} + +orgpath="$(pwd)" +repository="Orange-Management" +pos=$(strindex "$orgpath" "$repository") +length=$pos+${#repository} +rootpath=${orgpath:0:length} + +. ${rootpath}/Build/Hooks/delegator.sh diff --git a/Hooks/delegator.sh b/Hooks/delegator.sh index 644b458..64b4e2b 100644 --- a/Hooks/delegator.sh +++ b/Hooks/delegator.sh @@ -1,5 +1,5 @@ #!/bin/bash -. Build/Hooks/logging.sh -. Build/Hooks/syntax.sh -. Build/Hooks/filename.sh \ No newline at end of file +. ${rootpath}/Build/Hooks/logging.sh +. ${rootpath}/Build/Hooks/syntax.sh +. ${rootpath}/Build/Hooks/filename.sh \ No newline at end of file diff --git a/Hooks/logging.sh b/Hooks/logging.sh index 43a700f..ba565ae 100644 --- a/Hooks/logging.sh +++ b/Hooks/logging.sh @@ -4,7 +4,7 @@ git diff --cached --name-only | while read FILE; do if [[ "$FILE" =~ ^.+(php)$ ]]; then RESULT=$(grep "var_dump(" "$FILE") if [ ! -z $RESULT ]; then - echo -e "\e[1;33m\tWarning, the commit contains a call to var_dump(). Commit was not aborted, however.\e[0m" >&2 + echo -e "\e[1;33m\tWarning, the commit contains a call to var_dump() in '$FILE'. Commit was not aborted, however.\e[0m" >&2 fi fi done @@ -13,7 +13,7 @@ git diff --cached --name-only | while read FILE; do if [[ "$FILE" =~ ^.+(js)$ ]]; then RESULT=$(grep "console.log(" "$FILE") if [ ! -z $RESULT ]; then - echo -e "\e[1;33m\tWarning, the commit contains a call to console.log(). Commit was not aborted, however.\e[0m" >&2 + echo -e "\e[1;33m\tWarning, the commit contains a call to console.log() in '$FILE'. Commit was not aborted, however.\e[0m" >&2 fi fi done diff --git a/Hooks/syntax.sh b/Hooks/syntax.sh index 3874940..562eb23 100644 --- a/Hooks/syntax.sh +++ b/Hooks/syntax.sh @@ -13,14 +13,14 @@ if [[ "$FILE" =~ ^.+(php|inc|module|install|test)$ ]]; then fi # phpcs - ./vendor/bin/phpcs --standard="./Build/Config/phpcs.xml" --encoding=utf-8 -n -p $FILE + ${rootpath}/vendor/bin/phpcs --standard="${rootpath}/Build/Config/phpcs.xml" --encoding=utf-8 -n -p $FILE if [ $? -ne 0 ]; then echo -e "\e[1;31m\tCode Sniffer error.\e[0m" >&2 exit 1 fi # phpmd - ./vendor/bin/phpmd $FILE ./Build/Config/phpmd.xml --exclude *tests* --minimumpriority 1 + ${rootpath}/vendor/bin/phpmd $FILE text ${rootpath}/Build/Config/phpmd.xml --exclude *tests* --minimumpriority 1 if [ $? -ne 0 ]; then echo -e "\e[1;31m\tMess Detector error.\e[0m" >&2 exit 1