32 lines
662 B
Plaintext
32 lines
662 B
Plaintext
|
#!/bin/bash
|
||
|
|
||
|
STAGED_FILES=$(git diff --cached --name-only --diff-filter=ACM | grep ".php\{0,1\}$")
|
||
|
|
||
|
# Disable if it's a merge
|
||
|
git merge HEAD &> /dev/null
|
||
|
IS_MERGE_PROCESS=$?
|
||
|
if [ $IS_MERGE_PROCESS -ne 0 ]
|
||
|
then
|
||
|
echo -e "\e[92m Skipping pre-commit hook. \e[0m"
|
||
|
exit $?
|
||
|
fi
|
||
|
|
||
|
# Skip if no staged files
|
||
|
if [[ "$STAGED_FILES" = "" ]]; then
|
||
|
echo -e "\e[92m No staged files. Skipping pre-commit hook. \e[0m"
|
||
|
exit 0
|
||
|
fi
|
||
|
|
||
|
echo -e "\e[92m Running pre-commit hooks... \e[0m"
|
||
|
|
||
|
./artisan hooks:pre-commit
|
||
|
|
||
|
if [[ "$?" == 0 ]]; then
|
||
|
echo -e "\e[102m Pre-commit hooks passed \e[0m"
|
||
|
else
|
||
|
echo -e "\e[102m Pre-commit hooks failed \e[0m"
|
||
|
exit 1
|
||
|
fi
|
||
|
|
||
|
exit 0
|