Просмотр исходного кода

* Fixed bug in git helper: Do not fail if no tag could be read.

master
bergmann 6 лет назад
Родитель
Сommit
4c999fb0c6
1 измененных файлов: 22 добавлений и 6 удалений
  1. +22
    -6
      git_helper.cmake

+ 22
- 6
git_helper.cmake Просмотреть файл

@@ -1,5 +1,6 @@
# Execute git command and return the output
Function ( GitExecute COMMAND RESULT )
Function ( GitExecute COMMAND FORCE OUT_RESULT OUT_SUCCESS )
Set ( ${OUT_SUCCESS} 1 PARENT_SCOPE )
Execute_Process ( COMMAND
bash -c "${COMMAND}"
RESULT_VARIABLE
@@ -11,9 +12,13 @@ Function ( GitExecute COMMAND RESULT )
If ( NOT ${GIT_RET} EQUAL 0
OR NOT "${GIT_ERR}" STREQUAL ""
OR "${GIT_REV}" STREQUAL "" )
Message ( FATAL_ERROR "Unable to execute git command (command=${COMMAND} out=${GIT_REV}; err=${GIT_ERR}; ret=${GIT_RET})" )
If ( FORCE )
Message ( FATAL_ERROR "Unable to execute git command (command=${COMMAND} out=${GIT_REV}; err=${GIT_ERR}; ret=${GIT_RET})" )
Else ( )
Set ( ${OUT_SUCCESS} 0 PARENT_SCOPE )
EndIf ( )
EndIf ( )
Set ( ${RESULT} "${GIT_REV}" PARENT_SCOPE )
Set ( ${OUT_RESULT} "${GIT_REV}" PARENT_SCOPE )
EndFunction ( )

# Get the version by reading the git tag
@@ -24,9 +29,20 @@ Function ( GitGetVersion GIT_ROOT OUT_MAJOR OUT_MINOR OUT_PATCH OUT_BUILD OUT_HA
EndIf ( )

# Find the latest git tag
GitExecute ( "git describe --tags --abbrev=1 --match v[0-9].[0-9]* HEAD" TAG )
GitExecute ( "git status -s -uall" DIRTY )
GitExecute ( "git rev-parse HEAD" HASH )
GitExecute ( "git describe --tags --abbrev=1 --match v[0-9].[0-9]* HEAD" False TAG SUCCESS )
If ( NOT ${SUCCESS} )
Return ( )
EndIf ( )

GitExecute ( "git status -s -uall" True DIRTY SUCCESS )
If ( NOT ${SUCCESS} )
Return ( )
EndIf ( )

GitExecute ( "git rev-parse HEAD" True HASH SUCCESS )
If ( NOT ${SUCCESS} )
Return ( )
EndIf ( )

# Split the git revision string
String ( REGEX REPLACE "^v" "" TAG "${TAG}" )


Загрузка…
Отмена
Сохранить