ExternalProject: Always do a git fetch for a remote ref.
Remote git refs always require a git fetch, because the remote may move around where the ref points.
This commit is contained in:
parent
2619f4d87a
commit
9b66c8faf5
@ -418,6 +418,19 @@ if(error_code)
|
|||||||
message(FATAL_ERROR \"Failed to get the hash for HEAD\")
|
message(FATAL_ERROR \"Failed to get the hash for HEAD\")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
execute_process(
|
||||||
|
COMMAND \"${git_EXECUTABLE}\" show-ref ${git_tag}
|
||||||
|
WORKING_DIRECTORY \"${work_dir}\"
|
||||||
|
OUTPUT_VARIABLE show_ref_output
|
||||||
|
)
|
||||||
|
# If a remote ref is asked for, which can possibly move around,
|
||||||
|
# we must always do a fetch and checkout.
|
||||||
|
if(\"\${show_ref_output}\" MATCHES \"remotes\")
|
||||||
|
set(is_remote_ref 1)
|
||||||
|
else()
|
||||||
|
set(is_remote_ref 0)
|
||||||
|
endif()
|
||||||
|
|
||||||
# This will fail if the tag does not exist (it probably has not been fetched
|
# This will fail if the tag does not exist (it probably has not been fetched
|
||||||
# yet).
|
# yet).
|
||||||
execute_process(
|
execute_process(
|
||||||
@ -428,7 +441,7 @@ execute_process(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Is the hash checkout out that we want?
|
# Is the hash checkout out that we want?
|
||||||
if(error_code OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\"))
|
if(error_code OR is_remote_ref OR NOT (\"\${tag_sha}\" STREQUAL \"\${head_sha}\"))
|
||||||
execute_process(
|
execute_process(
|
||||||
COMMAND \"${git_EXECUTABLE}\" fetch
|
COMMAND \"${git_EXECUTABLE}\" fetch
|
||||||
WORKING_DIRECTORY \"${work_dir}\"
|
WORKING_DIRECTORY \"${work_dir}\"
|
||||||
|
@ -29,12 +29,12 @@ macro(check_a_tag desired_tag resulting_sha)
|
|||||||
WORKING_DIRECTORY ${ExternalProjectUpdate_BINARY_DIR}/CMakeExternals/Source/TutorialStep1-GIT
|
WORKING_DIRECTORY ${ExternalProjectUpdate_BINARY_DIR}/CMakeExternals/Source/TutorialStep1-GIT
|
||||||
RESULT_VARIABLE error_code
|
RESULT_VARIABLE error_code
|
||||||
OUTPUT_VARIABLE tag_sha
|
OUTPUT_VARIABLE tag_sha
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||||
)
|
)
|
||||||
if(error_code)
|
if(error_code)
|
||||||
message(FATAL_ERROR "Could not check the sha.")
|
message(FATAL_ERROR "Could not check the sha.")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
string(STRIP "${tag_sha}" tag_sha)
|
|
||||||
if(NOT (${tag_sha} STREQUAL ${resulting_sha}))
|
if(NOT (${tag_sha} STREQUAL ${resulting_sha}))
|
||||||
message(FATAL_ERROR "UPDATE_COMMAND produced
|
message(FATAL_ERROR "UPDATE_COMMAND produced
|
||||||
${tag_sha}
|
${tag_sha}
|
||||||
@ -55,4 +55,6 @@ if(GIT_EXECUTABLE)
|
|||||||
check_a_tag(tag2 5842b503ba4113976d9bb28d57b5aee1ad2736b7)
|
check_a_tag(tag2 5842b503ba4113976d9bb28d57b5aee1ad2736b7)
|
||||||
check_a_tag(d19707303 d1970730310fe8bc07e73f15dc570071f9f9654a)
|
check_a_tag(d19707303 d1970730310fe8bc07e73f15dc570071f9f9654a)
|
||||||
check_a_tag(origin/master 5842b503ba4113976d9bb28d57b5aee1ad2736b7)
|
check_a_tag(origin/master 5842b503ba4113976d9bb28d57b5aee1ad2736b7)
|
||||||
|
# This is a remote symbolic ref, so it will always trigger a 'git fetch'
|
||||||
|
check_a_tag(origin/master 5842b503ba4113976d9bb28d57b5aee1ad2736b7)
|
||||||
endif()
|
endif()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user