diff options
| author | 2015-06-21 14:21:02 -0700 | |
|---|---|---|
| committer | 2015-06-21 14:21:02 -0700 | |
| commit | 772ef097ead8d6be77cf00d753e8380fcac96710 (patch) | |
| tree | 70e74daf5c9d3159550c36367959727b224c8bb5 /hooks/pre-commit | |
| parent | AppVeyor: update WinSCP download link with one that should never expire (diff) | |
| parent | enforce config from hook (diff) | |
| download | yuzu-772ef097ead8d6be77cf00d753e8380fcac96710.tar.gz yuzu-772ef097ead8d6be77cf00d753e8380fcac96710.tar.xz yuzu-772ef097ead8d6be77cf00d753e8380fcac96710.zip | |
Merge pull request #839 from Lectem/whitespacepolicy
Enforce the "no tab, use spaces" policy with a pre-commit hook.
Diffstat (limited to 'hooks/pre-commit')
| -rw-r--r-- | hooks/pre-commit | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/hooks/pre-commit b/hooks/pre-commit new file mode 100644 index 000000000..bad84b14b --- /dev/null +++ b/hooks/pre-commit | |||
| @@ -0,0 +1,24 @@ | |||
| 1 | #!/bin/sh | ||
| 2 | |||
| 3 | # Enforce citra's whitespace policy | ||
| 4 | git config --local core.whitespace tab-in-indent,trailing-space | ||
| 5 | |||
| 6 | # If there are whitespace errors, print the offending file names and fail. | ||
| 7 | if ! git diff --cached --check; then | ||
| 8 | cat<<END; | ||
| 9 | |||
| 10 | Error: This commit would contain trailing spaces or tabs, which is against this repo's policy. | ||
| 11 | Please correct those issues before commiting. (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 | |||
| 17 | # Check for tabs, since tab-in-indent catches only those at the beginning of a line | ||
| 18 | if git diff --cached | 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 | ||