File tree Expand file tree Collapse file tree 1 file changed +11
-21
lines changed
Expand file tree Collapse file tree 1 file changed +11
-21
lines changed Original file line number Diff line number Diff line change @@ -7,17 +7,18 @@ PHP_CS_FIXER="${BIN_PATH}/php-cs-fixer"
77PHP_VERSION=' {{PHP_VERSION}}'
88PHP_PROJECT_PATH=' {{PHP_PROJECT_PATH}}'
99
10- cd ${PHP_PROJECT_PATH}
10+ # cd ${PHP_PROJECT_PATH}
1111# Code conflict's check
1212for file in $( git --no-pager diff --cached --name-only)
1313do
14- git show " :$file " | grep " <<< HEAD" > /dev/null
15- if [ $? -eq 0 ]; then
16- echo -e " \033[31m\033[43;31m${file} \033[0;31m Your code has conflict!\033[0m"
17- exit 1
18- fi
14+ git show " :$file " | grep " <<< HEAD" > /dev/null
15+ if [ $? -eq 0 ]; then
16+ echo -e " \033[31m\033[43;31m${file} \033[0;31m Your code has conflict!\033[0m"
17+ exit 1
18+ fi
1919done
2020
21+ # cd -
2122# php-cs-fixer's check
2223HAS_PHP_CS_FIXER=false
2324
@@ -44,22 +45,11 @@ if $HAS_PHP_CS_FIXER; then
4445 git status --porcelain | grep -e ' ^[AM]\(.*\).php$' | cut -c 3- | while read line; do
4546 output=$( ${PHP_CS_FIXER} fix ${CONFIG} --verbose ${line} --using-cache=no 2>&1 )
4647 echo " ${output} "
47- lines=$( echo " ${output} " | wc -l)
48- if [ ${lines} -eq 5 ]; then
49- dstLine=2
50- else
51- dstLine=3
48+ if ! echo " $output " | grep -E ' ^[\.F]$' ; then
49+ echo -e " \033[31mAttention:\033[43;31m${line} \033[0;31m,which not success !\033[0m"
50+ exit 1
5251 fi
53- marker=$( echo " ${output} " | sed -n -e " ${dstLine} p" )
54- case ${marker} in
55- ' .' |' F' )
56- git add " $line "
57- ;;
58- * )
59- echo -e " \033[31mAttention:\033[43;31m${line} \033[0;31m,which not success !\033[0m"
60- exit 1
61- ;;
62- esac
52+ git add " $line "
6353 done
6454 code=$?
6555 if [ ${code} -ne 0 ]; then
You can’t perform that action at this time.
0 commit comments