pre-commit 1.1 KB

123456789101112131415161718192021222324252627282930
  1. #!/bin/sh
  2. # SPDX-FileCopyrightText: 2015 Citra Emulator Project
  3. # SPDX-FileCopyrightText: 2024 suyu Emulator Project
  4. # SPDX-License-Identifier: GPL-2.0-or-later
  5. # Enforce suyu's whitespace policy
  6. git config --local core.whitespace tab-in-indent,trailing-space
  7. paths_to_check="src/ CMakeLists.txt"
  8. # If there are whitespace errors, print the offending file names and fail.
  9. if ! git diff --cached --check -- $paths_to_check ; then
  10. cat<<END
  11. Error: This commit would contain trailing spaces or tabs, which is against this repo's policy.
  12. Please correct those issues before committing. (Use 'git diff --check' for more details)
  13. If you know what you are doing, you can try 'git commit --no-verify' to bypass the check
  14. END
  15. exit 1
  16. fi
  17. # Check for tabs, since tab-in-indent catches only those at the beginning of a line
  18. if git diff --cached -- $paths_to_check | egrep '^\+.* '; then
  19. cat<<END
  20. Error: This commit would contain a tab, which is against this repo's policy.
  21. If you know what you are doing, you can try 'git commit --no-verify' to bypass the check.
  22. END
  23. exit 1
  24. fi