script.sh 855 B

1234567891011121314151617181920212223242526272829303132333435
  1. #!/bin/bash -ex
  2. # SPDX-FileCopyrightText: 2019 yuzu Emulator Project
  3. # SPDX-License-Identifier: GPL-2.0-or-later
  4. shopt -s nullglob globstar
  5. if grep -nrI '\s$' src **/*.yml **/*.txt **/*.md Doxyfile .gitignore .gitmodules .ci* dist/*.desktop \
  6. dist/*.svg dist/*.xml; then
  7. echo Trailing whitespace found, aborting
  8. exit 1
  9. fi
  10. # Default clang-format points to default 3.5 version one
  11. CLANG_FORMAT="${CLANG_FORMAT:-clang-format-15}"
  12. "$CLANG_FORMAT" --version
  13. # Turn off tracing for this because it's too verbose
  14. set +x
  15. # Check everything for branch pushes
  16. FILES_TO_LINT="$(find src/ -name '*.cpp' -or -name '*.h')"
  17. for f in $FILES_TO_LINT; do
  18. echo "$f"
  19. "$CLANG_FORMAT" -i "$f"
  20. done
  21. DIFF=$(git diff)
  22. if [ ! -z "$DIFF" ]; then
  23. echo "!!! Not compliant to coding style, here is the fix:"
  24. echo "$DIFF"
  25. exit 1
  26. fi