forked from GNUsocial/gnu-social
38 lines
1.1 KiB
Bash
Executable File
38 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env sh
|
|
|
|
root="$(git rev-parse --show-toplevel)"
|
|
|
|
# get the list of changed files that didn't get only partially added
|
|
staged_files="$(git status --porcelain | sed -rn "s/^[^ ][ ] (.*)/\1/p")"
|
|
|
|
if (! (: "${SKIP_ALL?}") 2>/dev/null) && (! (: "${SKIP_CS_FIX?}") 2>/dev/null); then
|
|
files=""
|
|
for staged in ${staged_files}; do
|
|
# work only with existing files
|
|
if [ -f "${staged}" ] && expr "${staged}" : '^.*\.php$' > /dev/null; then
|
|
# use php-cs-fixer and get flag of correction
|
|
files="${staged} ${files}"
|
|
fi
|
|
done
|
|
if [ -n "${files}" ]; then
|
|
echo "Running php-cs-fixer on edited files"
|
|
make cs-fixer "${files}"
|
|
git add "${files}"
|
|
fi
|
|
fi
|
|
|
|
if (! (: "${SKIP_ALL?}") 2>/dev/null) && (! (: "${SKIP_DOC_CHECK?}") 2>/dev/null); then
|
|
if echo "${staged_files}" | grep -F ".php" > /dev/null 2>&1; then
|
|
echo "Running php-doc-checker"
|
|
make doc-check < /dev/tty
|
|
fi
|
|
fi
|
|
|
|
if (! (: "${SKIP_ALL?}") 2>/dev/null) && (! (: "${SKIP_PHPSTAN?}") 2>/dev/null); then
|
|
echo "Running phpstan"
|
|
make phpstan
|
|
fi
|
|
|
|
# Only commit if there wasn't an error
|
|
exit $?
|