[BUGFIX] Fix CGL script to new return status strategy of php-cs-fixer
[Packages/TYPO3.CMS.git] / typo3 / sysext / core / Build / Scripts / cglFixMyCommit.sh
1 #!/bin/bash
2
3 #########################
4 #
5 # CGL check latest core commit.
6 #
7 # It expects to be run from the core root.
8 #
9 # To auto-fix single files, use the php-cs-fixer command directly
10 # substitute $FILE with a filename
11 #
12 ##########################
13
14 COUNTER=0
15 DRYRUN=""
16
17 if [ "$1" = "dryrun" ]
18 then
19 DRYRUN="--dry-run"
20 fi
21
22 for FILE in $(git diff-tree --no-commit-id --name-only -r HEAD | grep '.php$'); do
23 if [ -e $FILE ]
24 then
25 ./bin/php-cs-fixer fix $FILE \
26 -v $DRYRUN \
27 --config=Build/.php_cs
28
29 if [ "$?" -gt "0" ]
30 then
31 COUNTER=$((COUNTER+1))
32 fi
33 fi
34 done
35
36 if [ ${COUNTER} -gt 0 ] ; then
37 echo "$COUNTER number of files are not CGL clean. Check $0 to find out what is going wrong."
38 exit 1
39 fi
40
41 exit 0