diff --git a/Dockerfile b/Dockerfile index 3aa2204..949d175 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM php:7.4-cli +FROM php:8.1-cli COPY entrypoint.sh /entrypoint.sh diff --git a/entrypoint.sh b/entrypoint.sh index 6db0567..5c94a32 100644 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -4,11 +4,12 @@ ERROR=0 PATHS=$(printf ${MODIFIED_FILES} | tr \\n '\n') -echo "******************************** MODIFIED FILES ********************************" +printf "\n******************************** MODIFIED FILES ****************************************************************" +echo "" printf ${MODIFIED_FILES} -printf "\n********************************* ERRORS FOUND *******************************************************************" +printf "\n******************************** ERRORS FOUND ****************************************************************" -echo "$PATHS" | while read FILE ; do +while read FILE ; do if [[ ! -f $FILE ]]; then continue # skip deleted files @@ -24,24 +25,22 @@ echo "$PATHS" | while read FILE ; do BREAKLINE_TYPE=$(find $FILE -not -type d -exec file "{}" ";" | grep -o "CR\(LF\)\?") if [[ $CR_FOUND == 1 ]]; then - echo "\n* Whole file( $FILE ) breakline format is $BREAKLINE_TYPE , it should be LF" + printf "\n* Whole file( $FILE ) breakline format is $BREAKLINE_TYPE , it should be LF" ERROR=1 fi if [[ $CR_LINE_DETECTOR == 1 ]]; then - echo "\n* $BREAKLINE_TYPE line breaker found in $FILE:" + printf "\n* $BREAKLINE_TYPE line breaker found in $FILE:" cat -en $FILE | grep "\^M" | sed 's/\^M\$//g' - ERROR=1 fi -done +done <<< "$PATHS" + +printf "\n**************************************************************************************************************" if [[ $ERROR == 0 ]]; then printf "\n* No files with wrong breakline format found in changed files" -fi - -printf "\n******************************************************************************************************************\n" - - -if [[ $ERROR == 1 ]]; then + exit 0 +else + printf "\n* There are files with wrong breakline format, please fix them (see above)" exit 101 fi