Skip to content

Commit

Permalink
check .git before create pre-commit hook (#276)
Browse files Browse the repository at this point in the history
  • Loading branch information
darionyaphet authored and dangleptr committed Apr 19, 2019
1 parent e07b105 commit 2535772
Showing 1 changed file with 19 additions and 14 deletions.
33 changes: 19 additions & 14 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -310,19 +310,24 @@ add_custom_target(
)


# Create the pre-commit hook every time we run cmake
set(PRE_COMMIT_HOOK ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks/pre-commit)
execute_process(
COMMAND
"rm" "-f" ${PRE_COMMIT_HOOK}
)
execute_process(
COMMAND
"ln" "-s" ${CMAKE_CURRENT_SOURCE_DIR}/cpplint/bin/pre-commit.sh ${PRE_COMMIT_HOOK}
RESULT_VARIABLE retcode
)
IF(${retcode} EQUAL 0)
MESSAGE(STATUS "Creating pre-commit hook done")
IF(EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/.git/")
# Create the pre-commit hook every time we run cmake
message(STATUS "Create the pre-commit hook")
set(PRE_COMMIT_HOOK ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks/pre-commit)
execute_process(
COMMAND
"rm" "-f" ${PRE_COMMIT_HOOK}
)
execute_process(
COMMAND
"ln" "-s" ${CMAKE_CURRENT_SOURCE_DIR}/cpplint/bin/pre-commit.sh ${PRE_COMMIT_HOOK}
RESULT_VARIABLE retcode
)
IF(${retcode} EQUAL 0)
MESSAGE(STATUS "Creating pre-commit hook done")
ELSE()
MESSAGE(FATAL_ERROR "Creating pre-commit hook failed: ${retcode}")
ENDIF()
ELSE()
MESSAGE(FATAL_ERROR "Creating pre-commit hook failed: ${retcode}")
MESSAGE(FATAL_ERROR "Currently, we don't support downloaded source code.\nPlease using git clone it and rebuild.")
ENDIF()

0 comments on commit 2535772

Please sign in to comment.