diff --git a/test.cmake b/test.cmake index f7735cba1..d1c04f377 100755 --- a/test.cmake +++ b/test.cmake @@ -62,7 +62,8 @@ string(REPLACE "ref: refs/heads/" "" git_branch "${git_branch}") # -> user/fooba if(NOT git_branch MATCHES "^[0-9a-f]+$") # an actual branch name, not a hash # read the associated hash if(EXISTS "${CTEST_SOURCE_DIRECTORY}/.git/refs/heads/${git_branch}") - file(READ "${CTEST_SOURCE_DIRECTORY}/.git/refs/heads/${git_branch}" git_hash LIMIT 7) + set(git_hash_file "${CTEST_SOURCE_DIRECTORY}/.git/refs/heads/${git_branch}") + file(READ "${git_hash_file}" git_hash LIMIT 7) string(STRIP "${git_hash}" git_hash) endif() string(REGEX REPLACE "^.*/" "" git_branch "${git_branch}") @@ -285,8 +286,8 @@ if(NOT is_nightly) # nightly builds shouldn't contain the git hash, since it makes expected builds impossible string(STRIP "${git_hash} ${CTEST_BUILD_NAME}" CTEST_BUILD_NAME) # instead make sure the hash is included in the notes - if(EXISTS "${CTEST_SOURCE_DIRECTORY}/.git/refs/heads/${git_branch}") - list(APPEND CTEST_NOTES_FILES "${CTEST_SOURCE_DIRECTORY}/.git/refs/heads/${git_branch}") + if(DEFINED git_hash_file) + list(APPEND CTEST_NOTES_FILES "${git_hash_file}") endif() endif() if(DEFINED subset)