Skip to content

Commit 030fd01

Browse files
author
Roberto Di Remigio
committed
Use some git kung-fu to get last commit author name, author e-mail and date
1 parent 9b7278f commit 030fd01

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

cmake/build-info/ConfigGitRevision.cmake

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,16 @@ if(DEVELOPMENT_CODE)
2121
)
2222

2323
if(GIT_LAST_COMMIT)
24-
string(REGEX MATCH "Author:[ ]*(.+)<" temp "${GIT_LAST_COMMIT}")
25-
set(GIT_LAST_COMMIT_AUTHOR ${CMAKE_MATCH_1})
26-
string(REGEX MATCH "Date:[ ]*(.+(\\+|-)[0-9][0-9][0-9][0-9])" temp "${GIT_LAST_COMMIT}")
27-
set(GIT_LAST_COMMIT_DATE ${CMAKE_MATCH_1})
24+
execute_process(
25+
COMMAND ${GIT_EXECUTABLE} --no-pager log -1 --pretty=format:"%an <%ae>" HEAD
26+
OUTPUT_VARIABLE GIT_LAST_COMMIT_AUTHOR
27+
ERROR_QUIET
28+
)
29+
execute_process(
30+
COMMAND ${GIT_EXECUTABLE} --no-pager log -1 --pretty=format:"%ad" HEAD
31+
OUTPUT_VARIABLE GIT_LAST_COMMIT_DATE
32+
ERROR_QUIET
33+
)
2834
endif()
2935

3036
execute_process(

0 commit comments

Comments
 (0)