Skip to content

Commit

Permalink
CheckSubmodules: Workaround submodules failing (#5222)
Browse files Browse the repository at this point in the history
Workaround git's inability to recover from a shallow clone
  • Loading branch information
tresf authored Oct 6, 2019
1 parent 15fe551 commit da09b2a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cmake/modules/CheckSubmodules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,10 @@ MACRO(GIT_SUBMODULE SUBMODULE_PATH FORCE_DEINIT FORCE_REMOTE FULL_CLONE)
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
OUTPUT_QUIET
)
MESSAGE("-- Deleting ${CMAKE_SOURCE_DIR}/.git/${SUBMODULE_PATH}")
FILE(REMOVE_RECURSE "${CMAKE_SOURCE_DIR}/.git/modules/${SUBMODULE_PATH}")
# Recurse
GIT_SUBMODULE(${SUBMODULE_PATH} false false ${FULL_CLONE_FLAG})
GIT_SUBMODULE(${SUBMODULE_PATH} false false true)
ELSE()
# Try to use the depth switch
IF(NO_SHALLOW_CLONE OR GIT_VERSION_STRING VERSION_LESS "1.8.4")
Expand Down Expand Up @@ -179,11 +181,9 @@ FOREACH(_submodule ${SUBMODULE_LIST})
GIT_SUBMODULE("${_submodule}" false false false)

SET(COUNTED 0)
SET(COUNTING "")
# Handle edge-cases where submodule didn't clone properly or re-uses a non-empty directory
WHILE(NOT GIT_RESULT EQUAL 0 AND COUNTED LESS MAX_ATTEMPTS)
LIST(APPEND COUNTING "x")
LIST(LENGTH COUNTING COUNTED)
MATH(EXPR COUNTED "${COUNTED}+1")
SET(MISSING_COMMIT false)
FOREACH(_phrase ${MISSING_COMMIT_PHRASES})
IF("${GIT_MESSAGE}" MATCHES "${_phrase}")
Expand Down

0 comments on commit da09b2a

Please sign in to comment.