diff --git a/Makefile b/Makefile index 215b49b780..4ee0089f6c 100644 --- a/Makefile +++ b/Makefile @@ -46,7 +46,7 @@ test: tooling-docker docker exec $(call translate-container-name,tooling_php_1) /var/tooling/coverage.sh $(call args,'') cs-fixer: tooling-docker - @bin/php-cs-fixer $(call args,'') + @bin/php-cs-fixer $${CS_FIXER_FILE} doc-check: tooling-docker bin/php-doc-check diff --git a/bin/php-cs-fixer b/bin/php-cs-fixer index c1cc2f9c10..3cf9173a35 100755 --- a/bin/php-cs-fixer +++ b/bin/php-cs-fixer @@ -2,9 +2,8 @@ . bin/translate_container_name.sh -if [ "${#}" -eq 1 ]; then - docker exec "$(translate_container_name tooling_php_1)" /var/www/social/vendor/bin/php-cs-fixer -q -n --config=".php-cs-fixer.php" fix "${1}" -else - echo running without specific files? +if [ "$#" -eq 0 ] || [ -z "$*" ]; then docker exec "$(translate_container_name tooling_php_1)" /var/www/social/vendor/bin/php-cs-fixer -n --config=".php-cs-fixer.php" fix +else + docker exec "$(translate_container_name tooling_php_1)" sh -c "/var/www/social/vendor/bin/php-cs-fixer -q -n --config=\".php-cs-fixer.php\" fix --path-mode=intersection -- $*" fi diff --git a/bin/pre-commit b/bin/pre-commit index 9f3bf81f53..ce1c3a3c53 100755 --- a/bin/pre-commit +++ b/bin/pre-commit @@ -6,19 +6,15 @@ root="$(git rev-parse --show-toplevel)" staged_files="$(git status --porcelain | sed -rn "s/^[^ ][ ] (.*)/\1/p")" if (! (: "${SKIP_ALL?}") 2>/dev/null) && (! (: "${SKIP_CS_FIX?}") 2>/dev/null); then - files="" + echo "Running php-cs-fixer on edited 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}" + CS_FIXER_FILE="${staged}" make cs-fixer + git add "${staged}" 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