pre-commit 1.0 KB

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