summaryrefslogtreecommitdiff
path: root/.ci/scripts/format/script.sh
diff options
context:
space:
mode:
Diffstat (limited to '.ci/scripts/format/script.sh')
-rwxr-xr-x.ci/scripts/format/script.sh39
1 files changed, 18 insertions, 21 deletions
diff --git a/.ci/scripts/format/script.sh b/.ci/scripts/format/script.sh
index 25b0718f0..f9c63dbfa 100755
--- a/.ci/scripts/format/script.sh
+++ b/.ci/scripts/format/script.sh
@@ -3,38 +3,35 @@
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 dist/*.svg dist/*.xml; then 7
8if git grep -nrI '\s$' src **/*.yml **/*.txt **/*.md Doxyfile .gitignore .gitmodules .ci* dist/*.desktop dist/*.svg dist/*.xml; then
8 echo Trailing whitespace found, aborting 9 echo Trailing whitespace found, aborting
9 exit 1 10 exit 1
10fi 11fi
11 12
12# Default clang-format points to default 3.5 version one 13# Default clang-format points to default 3.5 version one
13CLANG_FORMAT=${CLANG_FORMAT:-clang-format-15} 14CLANG_FORMAT="${CLANG_FORMAT:-clang-format-15}"
14$CLANG_FORMAT --version 15"$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 16
24# Turn off tracing for this because it's too verbose 17# Turn off tracing for this because it's too verbose
25set +x 18set +x
26 19
27for f in $files_to_lint; do 20# Check everything for branch pushes
28 d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true) 21FILES_TO_LINT="$(find src/ -name '*.cpp' -or -name '*.h')"
29 if ! [ -z "$d" ]; then 22
30 echo "!!! $f not compliant to coding style, here is the fix:" 23for f in $FILES_TO_LINT; do
31 echo "$d" 24 echo "$f"
32 fail=1 25 "$CLANG_FORMAT" -i "$f"
33 fi
34done 26done
35 27
36set -x 28DIFF=$(git -c core.fileMode=false diff)
37 29
38if [ "$fail" = 1 ]; then 30if [ ! -z "$DIFF" ]; then
31 echo "!!! Not compliant to coding style, here is the fix:"
32 echo "$DIFF"
39 exit 1 33 exit 1
40fi 34fi
35
36cd src/android
37./gradlew ktlintCheck