| @@ -1,5 +1,6 @@ | |||||
| # Execute git command and return the output | # 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 | Execute_Process ( COMMAND | ||||
| bash -c "${COMMAND}" | bash -c "${COMMAND}" | ||||
| RESULT_VARIABLE | RESULT_VARIABLE | ||||
| @@ -11,9 +12,13 @@ Function ( GitExecute COMMAND RESULT ) | |||||
| If ( NOT ${GIT_RET} EQUAL 0 | If ( NOT ${GIT_RET} EQUAL 0 | ||||
| OR NOT "${GIT_ERR}" STREQUAL "" | OR NOT "${GIT_ERR}" STREQUAL "" | ||||
| OR "${GIT_REV}" 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 ( ) | EndIf ( ) | ||||
| Set ( ${RESULT} "${GIT_REV}" PARENT_SCOPE ) | |||||
| Set ( ${OUT_RESULT} "${GIT_REV}" PARENT_SCOPE ) | |||||
| EndFunction ( ) | EndFunction ( ) | ||||
| # Get the version by reading the git tag | # 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 ( ) | EndIf ( ) | ||||
| # Find the latest git tag | # 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 | # Split the git revision string | ||||
| String ( REGEX REPLACE "^v" "" TAG "${TAG}" ) | String ( REGEX REPLACE "^v" "" TAG "${TAG}" ) | ||||