File tree Expand file tree Collapse file tree 1 file changed +15
-3
lines changed
Expand file tree Collapse file tree 1 file changed +15
-3
lines changed Original file line number Diff line number Diff line change @@ -17,16 +17,28 @@ function(get_patch_from_git VERSION_PATCH VERSION_MAJOR)
1717 message (STATUS "Did not find git package." )
1818 set (PATCH 9999)
1919 else ()
20- # If no tags can be found, it is a git shallow clone
20+ # If no tags can be found, it is a git shallow clone or a new major
2121 execute_process (COMMAND
2222 ${GIT_EXECUTABLE} rev-list --count v${VERSION_MAJOR} .0..HEAD
2323 RESULT_VARIABLE RESULT_VAR
2424 OUTPUT_VARIABLE PATCH
2525 ERROR_QUIET
2626 WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} )
2727 if (RESULT_VAR) # since 0 is success, need invert it
28- message (STATUS "Did not be able to compute patch from v${VERSION_MAJOR} .0." )
29- set (PATCH 9999)
28+ message (STATUS "Did not be able to compute patch from 'v${VERSION_MAJOR} .0'." )
29+ execute_process (COMMAND
30+ ${GIT_EXECUTABLE} rev-parse --is-shallow-repository
31+ OUTPUT_VARIABLE IS_SHALLOW_VAR
32+ ERROR_QUIET
33+ WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
34+ )
35+ if (${IS_SHALLOW_VAR} MATCHES "false" )
36+ message (STATUS "Repo is not shallow, use 0 as patch." )
37+ set (PATCH 0)
38+ else ()
39+ message (STATUS "Repo is shallow, use 9999 as patch." )
40+ set (PATCH 9999)
41+ endif ()
3042 endif ()
3143 STRING (STRIP PATCH ${PATCH} )
3244 STRING (REGEX REPLACE "\n $" "" PATCH ${PATCH} )
You can’t perform that action at this time.
0 commit comments