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