Comment on syntax errors (#656)

This commit is contained in:
Anna Prosvetova
2021-08-17 18:48:13 +03:00
committed by GitHub
parent fe2b9718e1
commit 46502ac44a
2 changed files with 23 additions and 6 deletions

View File

@@ -3,7 +3,6 @@
# set -e
CLANG_FORMAT_BIN="/usr/bin/clang-format-12"
PATH="$HOME/.cargo/bin:${PATH}"
PROJECT_DIR=$(pwd)
@@ -19,14 +18,20 @@ C_FILES=$(find . \
ulimit -s 65536
$CLANG_FORMAT_BIN --version
$CLANG_FORMAT_BIN --verbose -style=file -n --Werror --ferror-limit=0 $C_FILES
c_syntax_rc=$?
errors=$($CLANG_FORMAT_BIN --verbose -style=file -n --Werror --ferror-limit=0 $C_FILES |& tee /dev/stderr | sed '/^Formatting/d')
if [[ $c_syntax_rc -eq 0 ]]; then
if [[ -z "$errors" ]]; then
echo "Code looks fine for me!"
exit 0
fi
if [[ -n "${SET_GH_OUTPUT}" ]]; then
errors="${errors//'%'/'%25'}"
errors="${errors//$'\n'/'%0A'}"
errors="${errors//$'\r'/'%0D'}"
echo "::set-output name=errors::$errors"
fi
read -p "Do you want fix syntax? (y/n): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1
cd $PROJECT_DIR