Commit 836115da authored by Craig Scott's avatar Craig Scott Committed by Kitware Robot
Browse files

Stage topic 'ep-update-git-hash-missing'

Topic-id: 6109
Topic-url: cmake/cmake!6109
parents 96d48083 5e941a54
Pipeline #227856 failed with stages
in 79 minutes and 38 seconds
......@@ -5,7 +5,7 @@ cmake_minimum_required(VERSION 3.5)
function(get_hash_for_ref ref out_var err_var)
execute_process(
COMMAND "@git_EXECUTABLE@" rev-parse "${ref}"
COMMAND "@git_EXECUTABLE@" rev-parse "${ref}^{commit}"
WORKING_DIRECTORY "@work_dir@"
RESULT_VARIABLE error_code
OUTPUT_VARIABLE ref_hash
......
......@@ -11,7 +11,7 @@ file(MAKE_DIRECTORY ${srcDir})
file(GLOB entries ${srcRepo}/*)
file(REMOVE_RECURSE ${entries} ${binDir})
file(TOUCH ${srcRepo}/firstFile.txt)
configure_file(${CMAKE_CURRENT_LIST_DIR}/FetchGitTags/CMakeLists.txt
configure_file(${CMAKE_CURRENT_LIST_DIR}/FetchGitRefs/CMakeLists.txt
${srcDir}/CMakeLists.txt COPYONLY)
function(execGitCommand)
......@@ -63,5 +63,22 @@ execGitCommand(commit -m "Second file")
execGitCommand(tag -a -m "Adding tag" tag_of_interest)
execGitCommand(reset --hard HEAD~1)
message(STATUS "Second configure-and-build")
message(STATUS "Configure-and-build, update to tag")
configureAndBuild(tag_of_interest)
# Do the same, but this time for a commit hash
file(TOUCH ${srcRepo}/thirdFile.txt)
execGitCommand(add thirdFile.txt)
execGitCommand(commit -m "Third file")
execGitCommand(tag -a -m "Adding another tag" check_for_hash)
execGitCommand(reset --hard HEAD~1)
execute_process(
WORKING_DIRECTORY ${srcRepo}
COMMAND ${GIT_EXECUTABLE} rev-parse check_for_hash
COMMAND_ERROR_IS_FATAL ANY
OUTPUT_VARIABLE commit_hash
OUTPUT_STRIP_TRAILING_WHITESPACE
)
message(STATUS "Configure-and-build, update to commit hash ${commit_hash}")
configureAndBuild(${commit_hash})
......@@ -185,6 +185,6 @@ if(GIT_EXECUTABLE)
# Note that there appear to be differences in where git writes its output to
# on some platforms. It may go to stdout or stderr, so force it to be merged.
set(RunCMake_TEST_OUTPUT_MERGE TRUE)
run_cmake(FetchGitTags)
run_cmake(FetchGitRefs)
set(RunCMake_TEST_OUTPUT_MERGE FALSE)
endif()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment