Skip to content

Commit 74e2288

Browse files
authored
Error handling added to EnforceSubmoduleVersions (#772)
1 parent 8fada47 commit 74e2288

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

cmake/EnforceSubmoduleVersions.cmake

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ function(check_submodule_commit name rel_path)
3636
RESULT_VARIABLE _rc)
3737

3838
if(_rc OR "${_baseline}" STREQUAL "")
39-
message(FATAL_ERROR "Could not query git-link for ${rel_path}: ${_err}")
39+
message(STATUS "Could not query git-link for ${rel_path}: ${_err}. Skipping Submodule Version Check.")
4040
endif()
4141

4242
# ensure the commit object exists (deepens shallow clones/branches)
@@ -60,12 +60,25 @@ function(check_submodule_commit name rel_path)
6060
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --verify HEAD
6161
WORKING_DIRECTORY "${_sub_dir}"
6262
OUTPUT_VARIABLE _head
63-
OUTPUT_STRIP_TRAILING_WHITESPACE)
63+
OUTPUT_STRIP_TRAILING_WHITESPACE
64+
ERROR_VARIABLE _err
65+
RESULT_VARIABLE _rc ERROR_QUIET)
66+
67+
if(_rc)
68+
message(STATUS "Could not get HEAD commit for ${name}: ${_err}. Skipping Submodule Version Check.")
69+
return()
70+
endif()
6471

6572
execute_process(COMMAND ${GIT_EXECUTABLE} merge-base --is-ancestor
6673
${_baseline} ${_head}
6774
WORKING_DIRECTORY "${_sub_dir}"
6875
RESULT_VARIABLE _is_anc ERROR_QUIET)
76+
77+
# Check if merge-base command failed (not just ancestry check)
78+
if(_is_anc EQUAL -1)
79+
message(WARNING "Could not determine ancestry for ${name} at ${_sub_dir}")
80+
return()
81+
endif()
6982

7083
if(_is_anc GREATER 0)
7184
message(FATAL_ERROR

0 commit comments

Comments
 (0)