diff options
Diffstat (limited to '')
| -rw-r--r-- | CMakeLists.txt | 7 | ||||
| -rw-r--r-- | hooks/pre-commit | 24 |
2 files changed, 31 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 75f519a1d..6805ebed8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt | |||
| @@ -4,6 +4,13 @@ cmake_minimum_required(VERSION 2.8.11) | |||
| 4 | 4 | ||
| 5 | project(citra) | 5 | project(citra) |
| 6 | 6 | ||
| 7 | if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks/pre-commit) | ||
| 8 | message(STATUS "Copying pre-commit hook") | ||
| 9 | file(COPY hooks/pre-commit | ||
| 10 | DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks | ||
| 11 | FILE_PERMISSIONS WORLD_EXECUTE ) | ||
| 12 | endif() | ||
| 13 | |||
| 7 | if (NOT MSVC) | 14 | if (NOT MSVC) |
| 8 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -pthread") | 15 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wno-attributes -pthread") |
| 9 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") | 16 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread") |
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 | ||