Skip to content

Commit

Permalink
Try parsing description instead
Browse files Browse the repository at this point in the history
  • Loading branch information
tresf committed Feb 11, 2025
1 parent e0bdf3d commit 242511c
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions cmake/modules/VersionInfo.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,17 @@ IF(GIT_FOUND AND NOT FORCE_VERSION)
# number from the environment and add it to the build metadata
if("$ENV{GITHUB_REF}" MATCHES "refs/pull/([0-9]+)/merge")
list(APPEND BUILD_METADATA "pr${CMAKE_MATCH_1}")
# Parse hash from merge description
# e.g. "Merge abc1234 into def4567"
execute_process(
COMMAND "${GIT_EXECUTABLE}" log --format=%h HEAD~1...HEAD~2
COMMAND "${GIT_EXECUTABLE}" git log -n 1 --format=%s
OUTPUT_VARIABLE COMMIT_HASH
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
TIMEOUT 10
OUTPUT_STRIP_TRAILING_WHITESPACE)
# If successful, use the first 7 characters to mimic github's hash style
if(COMMIT_HASH)
string(SUBSTRING "${COMMIT_HASH}" 0 7 COMMIT_HASH)
string(SUBSTRING "${COMMIT_HASH}" 7 7 COMMIT_HASH)
endif()
endif()

Expand Down

0 comments on commit 242511c

Please sign in to comment.