summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-x.ci/scripts/format/script.sh35
1 files changed, 15 insertions, 20 deletions
diff --git a/.ci/scripts/format/script.sh b/.ci/scripts/format/script.sh
index 25b0718f0..c9c5e4fac 100755
--- a/.ci/scripts/format/script.sh
+++ b/.ci/scripts/format/script.sh
@@ -3,38 +3,33 @@
3# SPDX-FileCopyrightText: 2019 yuzu Emulator Project 3# SPDX-FileCopyrightText: 2019 yuzu Emulator Project
4# SPDX-License-Identifier: GPL-2.0-or-later 4# SPDX-License-Identifier: GPL-2.0-or-later
5 5
6if grep -nrI '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .ci* dist/*.desktop \ 6shopt -s nullglob globstar
7
8if grep -nrI '\s$' src **/*.yml **/*.txt **/*.md Doxyfile .gitignore .gitmodules .ci* dist/*.desktop \
7 dist/*.svg dist/*.xml; then 9 dist/*.svg dist/*.xml; then
8 echo Trailing whitespace found, aborting 10 echo Trailing whitespace found, aborting
9 exit 1 11 exit 1
10fi 12fi
11 13
12# Default clang-format points to default 3.5 version one 14# Default clang-format points to default 3.5 version one
13CLANG_FORMAT=${CLANG_FORMAT:-clang-format-15} 15CLANG_FORMAT="${CLANG_FORMAT:-clang-format-15}"
14$CLANG_FORMAT --version 16"$CLANG_FORMAT" --version
15
16if [ "$TRAVIS_EVENT_TYPE" = "pull_request" ]; then
17 # Get list of every file modified in this pull request
18 files_to_lint="$(git diff --name-only --diff-filter=ACMRTUXB $TRAVIS_COMMIT_RANGE | grep '^src/[^.]*[.]\(cpp\|h\)$' || true)"
19else
20 # Check everything for branch pushes
21 files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')"
22fi
23 17
24# Turn off tracing for this because it's too verbose 18# Turn off tracing for this because it's too verbose
25set +x 19set +x
26 20
27for f in $files_to_lint; do 21# Check everything for branch pushes
28 d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true) 22FILES_TO_LINT="$(find src/ -name '*.cpp' -or -name '*.h')"
29 if ! [ -z "$d" ]; then 23
30 echo "!!! $f not compliant to coding style, here is the fix:" 24for f in $FILES_TO_LINT; do
31 echo "$d" 25 echo "$f"
32 fail=1 26 "$CLANG_FORMAT" -i "$f"
33 fi
34done 27done
35 28
36set -x 29DIFF=$(git diff)
37 30
38if [ "$fail" = 1 ]; then 31if [ ! -z "$DIFF" ]; then
32 echo "!!! Not compliant to coding style, here is the fix:"
33 echo "$DIFF"
39 exit 1 34 exit 1
40fi 35fi