gnu-social/bin/pre-commit
Hugo Sales 6546c088d9 [DOCTRINE][SCHEMADEF] Create a new metadata driver to allow us to continue using static schemaDef functions
This has the benefit of requiring fewer code changes, as well as providing a better isolation
between GNU social and symfony, useful in case the framework needs to be changed
2021-04-14 15:36:35 +00:00

25 lines
637 B
Bash
Executable File

#!/usr/bin/env bash
# get the list of changed files
staged_files=$(git diff --cached --name-only)
# build command to fix files
cmd="$(git rev-parse --show-toplevel)/vendor/bin/php-cs-fixer"
echo "Running php-cs-fixer on edited files"
for staged in ${staged_files}; do
# work only with existing files
if [[ -f ${staged} && ${staged} == *.php ]]; then
# use php-cs-fixer and get flag of correction
"${cmd}" -q fix "${staged}"
# if php-cs-fixer fix works, it returns 0
if [[ $? -eq 0 ]]; then
git add "${staged}" # execute git add directly
fi
fi
done
exit 0 # do commit