mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-05 23:41:44 +00:00
#1937 use git branch --contains instead show
This commit is contained in:
@@ -795,17 +795,15 @@ find_package (Git)
|
||||
if (GIT_FOUND)
|
||||
message("git found: ${GIT_EXECUTABLE} with version ${GIT_VERSION_STRING}")
|
||||
execute_process(
|
||||
COMMAND ${GIT_EXECUTABLE} show -s --pretty=%D HEAD
|
||||
COMMAND ${GIT_EXECUTABLE} branch --contains HEAD
|
||||
OUTPUT_VARIABLE git_branches
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
string(REPLACE ", " ";" git_branch_list "${git_branches}")
|
||||
string(REPLACE " -> " ";" git_branch_list "${git_branch_list}")
|
||||
string(REPLACE "\n" ";" git_branch_list "${git_branches}")
|
||||
foreach(git_branch_candidate IN ITEMS ${git_branch_list})
|
||||
if (NOT git_branch_candidate MATCHES "/")
|
||||
if (NOT git_branch_candidate MATCHES "^HEAD$")
|
||||
set(git_branch ${git_branch_candidate})
|
||||
endif()
|
||||
string(STRIP "${git_branch_candidate}" git_branch_candidate_2)
|
||||
if (NOT git_branch_candidate_2 MATCHES "^HEAD$")
|
||||
set(git_branch ${git_branch_candidate_2})
|
||||
endif()
|
||||
endforeach()
|
||||
execute_process(
|
||||
@@ -813,8 +811,8 @@ if (GIT_FOUND)
|
||||
OUTPUT_VARIABLE git_sha
|
||||
OUTPUT_STRIP_TRAILING_WHITESPACE
|
||||
)
|
||||
message(STATUS "IfcOpenShell branch ${git_branch}")
|
||||
message(STATUS "IfcOpenShell commit ${git_sha}")
|
||||
message(STATUS "IfcOpenShell branch: \"${git_branch}\"")
|
||||
message(STATUS "IfcOpenShell commit: \"${git_sha}\"")
|
||||
add_definitions(-DIFCOPENSHELL_BRANCH=${git_branch})
|
||||
add_definitions(-DIFCOPENSHELL_COMMIT=${git_sha})
|
||||
endif()
|
||||
|
||||
Reference in New Issue
Block a user