Imported Upstream version 3.25.0
[platform/upstream/cmake.git] / Tests / CheckSourceTree / check.cmake
1 # Give Git access to the real home directory to get user's settings.
2 if(DEFINED ENV{CTEST_REAL_HOME})
3   set(ENV{HOME} "$ENV{CTEST_REAL_HOME}")
4 endif()
5
6 execute_process(
7   COMMAND "${GIT_EXECUTABLE}" status
8   WORKING_DIRECTORY "${CMake_SOURCE_DIR}"
9   OUTPUT_VARIABLE output
10   ERROR_VARIABLE output
11   RESULT_VARIABLE result
12   )
13 string(REPLACE "\n" "\n  " output "  ${output}")
14 if(NOT result EQUAL 0)
15   message(FATAL_ERROR "'git status' failed (${result}):\n${output}")
16 endif()
17
18 if(output MATCHES "\n[ \t#]*(Changes |new file:|modified:|Untracked )")
19   message(FATAL_ERROR "The source tree is not clean.  'git status' reports:\n${output}")
20 endif()
21
22 message(STATUS "The source tree is clean.")