1
1
# ---------------------------------------------------------------------------- #
2
2
#
3
3
# Copyright (c) 2020 C++ Modern Framework
4
+ # https://github.com/cppmf/GitInfo.cmake
4
5
#
5
6
# ---------------------------------------------------------------------------- #
6
7
7
8
# ---------------------------------------------------------------------------- #
8
9
#
9
- # Following variables will be set when calling GitInfo
10
+ # The following variables will be set when calling GitInfo
10
11
#
11
12
# GIT_DIR: path to the project .git directory
12
13
# GIT_IS_DIRTY: whether or not the working tree is dirty
13
- # GIT_HEAD_BRANCH : name of the branch associated te HEAD
14
+ # GIT_HEAD_BRANCH : name of the branch associated with HEAD
14
15
# GIT_REVISION_HASH: current HEAD sha hash
15
- # GIT_REVISION: shorten version of GIT_REVISION_HASH
16
- # GIT_REVISION_NAME: name associated to GIT_REVISION_HASH
16
+ # GIT_REVISION: short version of GIT_REVISION_HASH
17
+ # GIT_REVISION_NAME: name associated with GIT_REVISION_HASH
17
18
# GIT_AUTHOR_NAME : author name
18
19
# GIT_AUTHOR_EMAIL : author email
19
20
# GIT_AUTHOR_DATE : author date
32
33
# source should point to the root project directory
33
34
function(GitInfo source)
34
35
35
- # Check is source is a valid path
36
+ # Check if source is a valid path
36
37
if(NOT EXISTS ${source})
37
38
message(FATAL_ERROR "'${source}' is not a valid path")
38
39
endif()
@@ -43,7 +44,6 @@ function(GitInfo source)
43
44
# Check if .git folder exist
44
45
if(EXISTS ${GIT_DIR})
45
46
46
- #
47
47
set(GIT_DIR "${GIT_DIR}" CACHE PATH "Project .git directory")
48
48
49
49
# Check if git is installed
@@ -70,29 +70,29 @@ function(GitInfo source)
70
70
set(GIT_IS_DIRTY OFF CACHE BOOL "Indicate if current branch is dirty")
71
71
endif()
72
72
73
- # name of the brack associated te HEAD
73
+ # name of the branch associated with HEAD
74
74
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
75
75
WORKING_DIRECTORY ${source}
76
76
OUTPUT_VARIABLE GIT_HEAD_BRANCH OUTPUT_STRIP_TRAILING_WHITESPACE)
77
- set(GIT_HEAD_BRANCH "${GIT_HEAD_BRANCH}" CACHE INTERNAL "name of the brack associated te HEAD")
77
+ set(GIT_HEAD_BRANCH "${GIT_HEAD_BRANCH}" CACHE INTERNAL "name of the branch associated with HEAD")
78
78
79
79
# git revision full hash
80
80
execute_process(COMMAND ${GIT_EXECUTABLE} show -s "--format=%H" HEAD
81
81
WORKING_DIRECTORY ${source}
82
82
OUTPUT_VARIABLE GIT_REVISION_HASH OUTPUT_STRIP_TRAILING_WHITESPACE)
83
83
set(GIT_REVISION_HASH "${GIT_REVISION_HASH}" CACHE INTERNAL "git revision full hash")
84
84
85
- # shorten version of git revision
85
+ # short version of git revision
86
86
execute_process(COMMAND ${GIT_EXECUTABLE} show -s "--format=%h" HEAD
87
87
WORKING_DIRECTORY ${source}
88
88
OUTPUT_VARIABLE GIT_REVISION OUTPUT_STRIP_TRAILING_WHITESPACE)
89
- set(GIT_REVISION "${GIT_REVISION}" CACHE INTERNAL "shorten version of git revision")
89
+ set(GIT_REVISION "${GIT_REVISION}" CACHE INTERNAL "short version of git revision")
90
90
91
- # shorten version of git revision name
91
+ # short version of git revision name
92
92
execute_process(COMMAND ${GIT_EXECUTABLE} show -s "--format=%s" HEAD
93
93
WORKING_DIRECTORY ${source}
94
94
OUTPUT_VARIABLE GIT_REVISION_NAME OUTPUT_STRIP_TRAILING_WHITESPACE)
95
- set(GIT_REVISION_NAME "${GIT_REVISION_NAME}" CACHE INTERNAL "shorten version of git revision name")
95
+ set(GIT_REVISION_NAME "${GIT_REVISION_NAME}" CACHE INTERNAL "short version of git revision name")
96
96
97
97
# author name
98
98
execute_process(COMMAND ${GIT_EXECUTABLE} show -s "--format=%an" HEAD
0 commit comments