mirror of
https://github.com/Karaka-Management/Build.git
synced 2026-02-07 23:28:41 +00:00
Implement global hooks and fix bugs
This commit is contained in:
parent
41459ae5cd
commit
24e77ffcfe
|
|
@ -26,11 +26,11 @@
|
||||||
<rule ref="Generic.PHP.DisallowAlternativePHPTags"/>
|
<rule ref="Generic.PHP.DisallowAlternativePHPTags"/>
|
||||||
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
|
<rule ref="Generic.PHP.DisallowShortOpenTag"/>
|
||||||
<rule ref="Generic.PHP.DiscourageGoto"/>
|
<rule ref="Generic.PHP.DiscourageGoto"/>
|
||||||
<rule ref="Generic.PHP.ForbiddenFunctions">
|
<!--<rule ref="Generic.PHP.ForbiddenFunctions">
|
||||||
<properties>
|
<properties>
|
||||||
<property name="forbiddenFunctions" type="array" value="delete=>unset,print=>echo,create_function=>null" />
|
<property name="forbiddenFunctions" type="array" value="delete=>unset,print=>echo,create_function=>null" />
|
||||||
</properties>
|
</properties>
|
||||||
</rule>
|
</rule>-->
|
||||||
<rule ref="Generic.Files.ByteOrderMark"/>
|
<rule ref="Generic.Files.ByteOrderMark"/>
|
||||||
<rule ref="Generic.Files.LineLength">
|
<rule ref="Generic.Files.LineLength">
|
||||||
<rule ref="Generic.Files.OneTraitPerFile"/>
|
<rule ref="Generic.Files.OneTraitPerFile"/>
|
||||||
|
|
@ -130,7 +130,6 @@
|
||||||
<rule ref="Squiz.Functions.GlobalFunction">
|
<rule ref="Squiz.Functions.GlobalFunction">
|
||||||
<exclude-pattern>*/tests/*</exclude-pattern>
|
<exclude-pattern>*/tests/*</exclude-pattern>
|
||||||
</rule>
|
</rule>
|
||||||
<rule ref="Squiz.PHP.ForbiddenFunctions"/>
|
|
||||||
<rule ref="Squiz.PHP.GlobalKeyword"/>
|
<rule ref="Squiz.PHP.GlobalKeyword"/>
|
||||||
<rule ref="Squiz.PHP.NonExecutableCode"/>
|
<rule ref="Squiz.PHP.NonExecutableCode"/>
|
||||||
<rule ref="Squiz.Scope.StaticThisUsage"/>
|
<rule ref="Squiz.Scope.StaticThisUsage"/>
|
||||||
|
|
|
||||||
14
Hooks/default.sh
Normal file
14
Hooks/default.sh
Normal file
|
|
@ -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
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
. Build/Hooks/logging.sh
|
. ${rootpath}/Build/Hooks/logging.sh
|
||||||
. Build/Hooks/syntax.sh
|
. ${rootpath}/Build/Hooks/syntax.sh
|
||||||
. Build/Hooks/filename.sh
|
. ${rootpath}/Build/Hooks/filename.sh
|
||||||
|
|
@ -4,7 +4,7 @@ git diff --cached --name-only | while read FILE; do
|
||||||
if [[ "$FILE" =~ ^.+(php)$ ]]; then
|
if [[ "$FILE" =~ ^.+(php)$ ]]; then
|
||||||
RESULT=$(grep "var_dump(" "$FILE")
|
RESULT=$(grep "var_dump(" "$FILE")
|
||||||
if [ ! -z $RESULT ]; then
|
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
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
@ -13,7 +13,7 @@ git diff --cached --name-only | while read FILE; do
|
||||||
if [[ "$FILE" =~ ^.+(js)$ ]]; then
|
if [[ "$FILE" =~ ^.+(js)$ ]]; then
|
||||||
RESULT=$(grep "console.log(" "$FILE")
|
RESULT=$(grep "console.log(" "$FILE")
|
||||||
if [ ! -z $RESULT ]; then
|
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
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
|
||||||
|
|
@ -13,14 +13,14 @@ if [[ "$FILE" =~ ^.+(php|inc|module|install|test)$ ]]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# phpcs
|
# 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
|
if [ $? -ne 0 ]; then
|
||||||
echo -e "\e[1;31m\tCode Sniffer error.\e[0m" >&2
|
echo -e "\e[1;31m\tCode Sniffer error.\e[0m" >&2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# phpmd
|
# 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
|
if [ $? -ne 0 ]; then
|
||||||
echo -e "\e[1;31m\tMess Detector error.\e[0m" >&2
|
echo -e "\e[1;31m\tMess Detector error.\e[0m" >&2
|
||||||
exit 1
|
exit 1
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user