Skip to content

Commit

Permalink
Add an optional "---fix" argument to format-checking script
Browse files Browse the repository at this point in the history
  • Loading branch information
VasylBaran committed Sep 4, 2024
1 parent df3b461 commit 183338d
Showing 1 changed file with 14 additions and 5 deletions.
19 changes: 14 additions & 5 deletions .ci/clang-format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@
# SPDX-FileCopyrightText: 2023 Citra Emulator Project
# 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 \
dist/*.svg dist/*.xml; then
echo Trailing whitespace found, aborting
Expand All @@ -25,11 +30,15 @@ fi
set +x

for f in $files_to_lint; do
d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true)
if ! [ -z "$d" ]; then
echo "!!! $f not compliant to coding style, here is the fix:"
echo "$d"
fail=1
if [ "$fix" = true ]; then
$CLANG_FORMAT -i "$f"
else
d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true)
if ! [ -z "$d" ]; then
echo "!!! $f not compliant to coding style, here is the fix:"
echo "$d"
fail=1
fi
fi
done

Expand Down

0 comments on commit 183338d

Please sign in to comment.