Add an optional "---fix" argument to format-checking script

This commit is contained in:
VasylBaran 2024-07-28 18:51:37 +03:00 committed by Vasyl Baran
parent 221eb28815
commit 990233336f
1 changed files with 14 additions and 5 deletions

View File

@ -3,6 +3,11 @@
# SPDX-FileCopyrightText: 2023 Citra Emulator Project # SPDX-FileCopyrightText: 2023 Citra Emulator Project
# SPDX-License-Identifier: GPL-2.0-or-later # SPDX-License-Identifier: GPL-2.0-or-later
fix=false
if [ "$1" == "--fix" ]; then
fix=true
fi
if grep -nrI '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .ci* dist/*.desktop \ if grep -nrI '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .ci* dist/*.desktop \
dist/*.svg dist/*.xml; then dist/*.svg dist/*.xml; then
echo Trailing whitespace found, aborting echo Trailing whitespace found, aborting
@ -25,12 +30,16 @@ fi
set +x set +x
for f in $files_to_lint; do for f in $files_to_lint; do
if [ "$fix" = true ]; then
$CLANG_FORMAT -i "$f"
else
d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true) d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true)
if ! [ -z "$d" ]; then if ! [ -z "$d" ]; then
echo "!!! $f not compliant to coding style, here is the fix:" echo "!!! $f not compliant to coding style, here is the fix:"
echo "$d" echo "$d"
fail=1 fail=1
fi fi
fi
done done
set -x set -x