Buildinfo: Improve behavior with detached HEAD
Try real hard to detect which branch we've detached from.
This commit is contained in:
@@ -27,13 +27,12 @@ if(EXISTS ${SOURCE_DIR}/.git)
|
|||||||
OUTPUT_VARIABLE MY_WC_HASH
|
OUTPUT_VARIABLE MY_WC_HASH
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
execute_process(COMMAND git branch --list master --contains ${MY_WC_HASH}
|
execute_process(COMMAND git branch --list master blender-v* --contains ${MY_WC_HASH}
|
||||||
WORKING_DIRECTORY ${SOURCE_DIR}
|
WORKING_DIRECTORY ${SOURCE_DIR}
|
||||||
OUTPUT_VARIABLE _git_contains_check
|
OUTPUT_VARIABLE _git_contains_check
|
||||||
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
|
||||||
STRING(REGEX REPLACE "^[ \t]+" "" _git_contains_check "${_git_contains_check}")
|
if(NOT _git_contains_check STREQUAL "")
|
||||||
if(_git_contains_check STREQUAL "master")
|
|
||||||
set(MY_WC_BRANCH "master")
|
set(MY_WC_BRANCH "master")
|
||||||
else()
|
else()
|
||||||
execute_process(COMMAND git show-ref --tags -d
|
execute_process(COMMAND git show-ref --tags -d
|
||||||
@@ -48,6 +47,22 @@ if(EXISTS ${SOURCE_DIR}/.git)
|
|||||||
|
|
||||||
if(_git_tag_hashes MATCHES "${_git_head_hash}")
|
if(_git_tag_hashes MATCHES "${_git_head_hash}")
|
||||||
set(MY_WC_BRANCH "master")
|
set(MY_WC_BRANCH "master")
|
||||||
|
else()
|
||||||
|
execute_process(COMMAND git branch --contains ${MY_WC_HASH}
|
||||||
|
WORKING_DIRECTORY ${SOURCE_DIR}
|
||||||
|
OUTPUT_VARIABLE _git_contains_branches
|
||||||
|
OUTPUT_STRIP_TRAILING_WHITESPACE)
|
||||||
|
string(REGEX REPLACE "^\\*[ \t]+" "" _git_contains_branches "${_git_contains_branches}")
|
||||||
|
string(REGEX REPLACE "[\r\n]+" ";" _git_contains_branches "${_git_contains_branches}")
|
||||||
|
string(REGEX REPLACE ";[ \t]+" ";" _git_contains_branches "${_git_contains_branches}")
|
||||||
|
foreach(_branch ${_git_contains_branches})
|
||||||
|
if (NOT "${_branch}" MATCHES "\\(HEAD.*")
|
||||||
|
set(MY_WC_BRANCH "${_branch}")
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
unset(_branch)
|
||||||
|
unset(_git_contains_branches)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
unset(_git_tag_hashes)
|
unset(_git_tag_hashes)
|
||||||
|
Reference in New Issue
Block a user