forked from GNUsocial/gnu-social
6546c088d9
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
25 lines
637 B
Bash
Executable File
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
|