Add an optional "---fix" argument to format-checking script
This commit is contained in:
parent
221eb28815
commit
990233336f
|
@ -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,11 +30,15 @@ fi
|
||||||
set +x
|
set +x
|
||||||
|
|
||||||
for f in $files_to_lint; do
|
for f in $files_to_lint; do
|
||||||
d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true)
|
if [ "$fix" = true ]; then
|
||||||
if ! [ -z "$d" ]; then
|
$CLANG_FORMAT -i "$f"
|
||||||
echo "!!! $f not compliant to coding style, here is the fix:"
|
else
|
||||||
echo "$d"
|
d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true)
|
||||||
fail=1
|
if ! [ -z "$d" ]; then
|
||||||
|
echo "!!! $f not compliant to coding style, here is the fix:"
|
||||||
|
echo "$d"
|
||||||
|
fail=1
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue