From 3acaa53a16419e1eff93c1af54385153f5f88609 Mon Sep 17 00:00:00 2001 From: Nicolas Capens Date: Mon, 18 Apr 2022 00:36:49 -0400 Subject: Automate downloading .git/hooks/commit-msg SwiftShader's Gerrit Git host was recently configured to require a Change-Id in every commit message before accepting a pushed change for review. This CL makes CMake download the commit hook script which adds this Change-Id line, if not present, and makes it executable. Bug: Automate commit hook download. Change-Id: I627941b906f7fff54832d200b243dfc7a88ca479 Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/65129 Kokoro-Result: kokoro Tested-by: Nicolas Capens Reviewed-by: Sean Risser --- CMakeLists.txt | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3ff561345..c69489c00 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -101,6 +101,27 @@ if(CCACHE_FOUND) set_property(GLOBAL PROPERTY RULE_LAUNCH_LINK ccache) endif() +########################################################### +# Install Gerrit commit hook +########################################################### + +if(NOT EXISTS ${CMAKE_SOURCE_DIR}/.git/hooks/commit-msg) + message(WARNING " + .git/hooks/commit-msg was not found. + Downloading from https://gerrit-review.googlesource.com/tools/hooks/commit-msg... + ") + + file(DOWNLOAD https://gerrit-review.googlesource.com/tools/hooks/commit-msg ${CMAKE_SOURCE_DIR}/commit-msg) + + file(COPY ${CMAKE_SOURCE_DIR}/commit-msg + DESTINATION ${CMAKE_SOURCE_DIR}/.git/hooks/ + FILE_PERMISSIONS + OWNER_READ OWNER_WRITE OWNER_EXECUTE + GROUP_READ GROUP_WRITE GROUP_EXECUTE + WORLD_READ WORLD_EXECUTE) + file(REMOVE ${CMAKE_SOURCE_DIR}/commit-msg) +endif() + ########################################################### # Host libraries ########################################################### -- cgit v1.2.3