diff --git a/CMakeLists.txt b/CMakeLists.txt index 1c2ac93cb..8f3554ac2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -143,7 +143,9 @@ endif() # files used can be seen here: # https://git-scm.com/book/en/v2/Git-Internals-Git-References set(git_directory "${CMAKE_SOURCE_DIR}/.git") -if (EXISTS "${git_directory}") +# Check for directory because if the repo is cloned as a git submodule, .git is +# a file and below code doesn't work. +if (IS_DIRECTORY "${git_directory}") set_property(DIRECTORY APPEND PROPERTY CMAKE_CONFIGURE_DEPENDS "${git_directory}/HEAD") file(STRINGS "${git_directory}/HEAD" git_head_data) diff --git a/init b/init index 029160f88..036e7ee20 100755 --- a/init +++ b/init @@ -102,11 +102,15 @@ setup_virtualenv tests/integration/ldap echo "Done installing dependencies for Memgraph" -echo "Linking git hooks" -for hook in $(find $DIR/.githooks -type f -printf "%f\n"); do - ln -s -f "$DIR/.githooks/$hook" "$DIR/.git/hooks/$hook" - echo "Added $hook hook" -done; +echo "Linking git hooks OR skip if .git folder is not there" +if [ -d "$DIR/.git" ]; then + for hook in $(find $DIR/.githooks -type f -printf "%f\n"); do + ln -s -f "$DIR/.githooks/$hook" "$DIR/.git/hooks/$hook" + echo "Added $hook hook" + done; +else + echo "WARNING: .git folder not present, skip adding hooks" +fi # Install precommit hook except on old operating systems because we don't # develop on them -> pre-commit hook not required -> we can use latest