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 <noreply+kokoro@google.com>
Tested-by: Nicolas Capens <nicolascapens@google.com>
Reviewed-by: Sean Risser <srisser@google.com>
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 3ff5613..c69489c 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -102,6 +102,27 @@
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
###########################################################