3 # INSTRUCTION: Copy this file to .git/hooks/pre-commit
5 DBSTRUCTURE_PHP="static/dbstructure.config.php"
7 # You might have to change this to run the unit tests:
8 UNIT_TEST_SCRIPT="/some/path/run_unit_tests.sh"
10 echo "$0: Checking syntax and code-style ..."
11 CHANGES=$(git status | grep "modified:" | grep ".php" | cut -d ":" -f 2)
14 for CHANGE in ${CHANGES};
16 CHECK=$(php -l ${CHANGE} | grep -v "No syntax errors detected in")
22 CHECK=$(./bin/dev/php-cs-fixer/vendor/bin/php-cs-fixer fix --dry-run ${CHANGE})
23 if [ "$$" != "0" -a "$$" -lt 100 ]
25 echo "$0: Found code-style issue in '${CHANGE}'."
32 echo "$0: Some error(s) were found."
36 DBSTRUCTURE=$(echo "${CHANGES}" | grep "${DBSTRUCTURE_PHP}")
37 if [ -n "${DBSTRUCTURE}" ]
39 echo "$0: '${DBSTRUCTURE_PHP}' has changed. Updating documentation ..."
40 ./bin/console dbstructure dumpsql > database.sql || exit 255
41 git add database.sql doc/database/*.md
44 echo "$0: Running unit tests ..."
47 echo "$0: STATUS='${STATUS}'"
49 echo "$0: All checks passed."