diff options
| author | 2024-01-08 09:15:19 -0500 | |
|---|---|---|
| committer | 2024-01-08 09:52:25 -0500 | |
| commit | 30743eff5669a5557b1c00424f84865b8b3ff6ad (patch) | |
| tree | dd2d450cbca335b7a732f22b3487e68124023a64 | |
| parent | general: fix trailing whitespace (diff) | |
| download | yuzu-30743eff5669a5557b1c00424f84865b8b3ff6ad.tar.gz yuzu-30743eff5669a5557b1c00424f84865b8b3ff6ad.tar.xz yuzu-30743eff5669a5557b1c00424f84865b8b3ff6ad.zip | |
ci: make verify format workflow output more helpful
Diffstat (limited to '')
| -rwxr-xr-x | .ci/scripts/format/script.sh | 35 |
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 | ||
| 6 | if grep -nrI '\s$' src *.yml *.txt *.md Doxyfile .gitignore .gitmodules .ci* dist/*.desktop \ | 6 | shopt -s nullglob globstar |
| 7 | |||
| 8 | if 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 |
| 10 | fi | 12 | fi |
| 11 | 13 | ||
| 12 | # Default clang-format points to default 3.5 version one | 14 | # Default clang-format points to default 3.5 version one |
| 13 | CLANG_FORMAT=${CLANG_FORMAT:-clang-format-15} | 15 | CLANG_FORMAT="${CLANG_FORMAT:-clang-format-15}" |
| 14 | $CLANG_FORMAT --version | 16 | "$CLANG_FORMAT" --version |
| 15 | |||
| 16 | if [ "$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)" | ||
| 19 | else | ||
| 20 | # Check everything for branch pushes | ||
| 21 | files_to_lint="$(find src/ -name '*.cpp' -or -name '*.h')" | ||
| 22 | fi | ||
| 23 | 17 | ||
| 24 | # Turn off tracing for this because it's too verbose | 18 | # Turn off tracing for this because it's too verbose |
| 25 | set +x | 19 | set +x |
| 26 | 20 | ||
| 27 | for f in $files_to_lint; do | 21 | # Check everything for branch pushes |
| 28 | d=$(diff -u "$f" <($CLANG_FORMAT "$f") || true) | 22 | FILES_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:" | 24 | for f in $FILES_TO_LINT; do |
| 31 | echo "$d" | 25 | echo "$f" |
| 32 | fail=1 | 26 | "$CLANG_FORMAT" -i "$f" |
| 33 | fi | ||
| 34 | done | 27 | done |
| 35 | 28 | ||
| 36 | set -x | 29 | DIFF=$(git diff) |
| 37 | 30 | ||
| 38 | if [ "$fail" = 1 ]; then | 31 | if [ ! -z "$DIFF" ]; then |
| 32 | echo "!!! Not compliant to coding style, here is the fix:" | ||
| 33 | echo "$DIFF" | ||
| 39 | exit 1 | 34 | exit 1 |
| 40 | fi | 35 | fi |