aboutsummaryrefslogtreecommitdiffstats
path: root/git-tools
diff options
context:
space:
mode:
authorDavid King <imkingdavid@gmail.com>2013-07-11 20:43:41 -0400
committerDavid King <imkingdavid@gmail.com>2013-07-11 20:43:41 -0400
commit8b7aef6f938bf7c08d41908e78b6e71117adba38 (patch)
treed39d9f3720e4afe78d23772e15830a2b12f1f5ba /git-tools
parentb9c290b5480a958eabeef66d5e9af799f77e4566 (diff)
parentb1d3c1bf6990c8105c18eb9db06ebf9c974b0899 (diff)
downloadforums-8b7aef6f938bf7c08d41908e78b6e71117adba38.tar
forums-8b7aef6f938bf7c08d41908e78b6e71117adba38.tar.gz
forums-8b7aef6f938bf7c08d41908e78b6e71117adba38.tar.bz2
forums-8b7aef6f938bf7c08d41908e78b6e71117adba38.tar.xz
forums-8b7aef6f938bf7c08d41908e78b6e71117adba38.zip
Merge branch 'develop' into ticket/11215
* develop: (176 commits) [feature/bootstrap-dic] Bootstrap container from config.php [ticket/11548] Use new static methods for request and submit [ticket/10772] Updating tests [ticket/10772] Remove 3.1 code [ticket/11388] Add newlines at EOF [ticket/11388] INCLUDECSS [ticket/11548] Run array_map on complete error array and not just colour_error [ticket/11644] Skip phpbb_dbal_order_lower_test on MySQL 5.6 [ticket/11388] Do not append assets_version if using remote path (e.g. http) [ticket/11388] Fix typo [ticket/11388] Remove typehints (causing tests to fail) [ticket/11388] Disable cache if IN_INSTALL defined [ticket/11388] Do not modify by reference [ticket/11388] typehits [ticket/11388] INCLUDEJS test for //(url) [ticket/11388] INCLUDEJS supports //(url) [ticket/11388] Fixing includejs test [ticket/11388] includejs inherit from includeasset [feature/twig] Unit tests for includejs [ticket/8319] Add migration file for update change ...
Diffstat (limited to 'git-tools')
-rwxr-xr-xgit-tools/hooks/pre-commit57
1 files changed, 5 insertions, 52 deletions
diff --git a/git-tools/hooks/pre-commit b/git-tools/hooks/pre-commit
index 03babe47cd..06ba15c7fa 100755
--- a/git-tools/hooks/pre-commit
+++ b/git-tools/hooks/pre-commit
@@ -33,9 +33,7 @@ else
against=4b825dc642cb6eb9a060e54bf8d69288fbee4904
fi
-error=0
errors=""
-
if ! which "$PHP_BIN" >/dev/null 2>&1
then
echo "PHP Syntax check failed:"
@@ -73,63 +71,18 @@ do
# check the staged file content for syntax errors
# using php -l (lint)
- # note: if display_errors=stderr in php.ini,
- # parse errors are printed on stderr; otherwise
- # they are printed on stdout.
- # we filter everything other than parse errors
- # with a grep below, therefore it should be safe
- # to combine stdout and stderr in all circumstances
- result=$(git cat-file -p $sha | "$PHP_BIN" -l 2>&1)
+ result=$(git cat-file -p $sha | "$PHP_BIN" -n -l -ddisplay_errors\=1 -derror_reporting\=E_ALL -dlog_errrors\=0 2>&1)
if [ $? -ne 0 ]
then
- error=1
# Swap back in correct filenames
- errors=$(echo "$errors"; echo "$result" |sed -e "s@in - on@in $filename on@g")
+ errors=$(echo "$errors"; echo "$result" | grep ':' | sed -e "s@in - on@in $filename on@g")
fi
done
unset IFS
-if [ $error -eq 1 ]
+if [ -n "$errors" ]
then
- echo "PHP Syntax check failed:"
- # php "display errors" (display_errors php.ini value)
- # and "log errors" (log_errors php.ini value).
- # these are independent settings - see main/main.c in php source.
- # the "log errors" setting produces output which
- # starts with "PHP Parse error:"; the "display errors"
- # setting produces output starting with "Parse error:".
- # if both are turned on php dumps the parse error twice.
- # therefore here we try to grep for one version and
- # if that yields no results grep for the other version.
- #
- # other fun php facts:
- #
- # 1. in cli, display_errors and log_errors have different
- # destinations by default. display_errors prints to
- # standard output and log_errors prints to standard error.
- # whether these destinations make sense is left
- # as an exercise for the reader.
- # 2. as mentioned above, with all output turned on
- # php will print parse errors twice, one time on stdout
- # and one time on stderr.
- # 3. it is possible to set both display_errors and log_errors
- # to off. if this is done php will print the text
- # "Errors parsing <file>" but will not say what
- # the errors are. useful behavior, this.
- # 4. on my system display_errors defaults to on and
- # log_errors defaults to off, therefore providing
- # by default one copy of messages. your mileage may vary.
- # 5. by setting display_errors=stderr and log_errors=on,
- # both sets of messages will be printed on stderr.
- # 6. php-cgi binary, given display_errors=stderr and
- # log_errors=on, still prints both sets of messages
- # on stderr, but formats one set as an html fragment.
- # 7. your entry here? ;)
- $echo_e "$errors" | grep "^Parse error:"
- if [ $? -ne 0 ]
- then
- # match failed
- $echo_e "$errors" | grep "^PHP Parse error:"
- fi
+ echo "PHP Syntax check failed: "
+ $echo_e "$errors"
exit 1
fi