Browse Source

git_helper: use GIT_ROOT as working directory and not the -C option of git to fix usage in Windows

master
klno 2 years ago
parent
commit
f7805727a2
1 changed files with 8 additions and 6 deletions
  1. +8
    -6
      cmake/git_helper.cmake

+ 8
- 6
cmake/git_helper.cmake View File

@@ -1,8 +1,10 @@
# Execute git command and return the output
Function ( GitExecute COMMAND FORCE OUT_RESULT OUT_SUCCESS )
Function ( GitExecute GIT_ROOT COMMAND FORCE OUT_RESULT OUT_SUCCESS )
Set ( ${OUT_SUCCESS} 1 PARENT_SCOPE )
Execute_Process ( COMMAND
bash -c "${COMMAND}"
WORKING_DIRECTORY
"${GIT_ROOT}"
RESULT_VARIABLE
GIT_RET
OUTPUT_VARIABLE
@@ -28,17 +30,17 @@ Function ( GitGetVersion GIT_ROOT OUT_MAJOR OUT_MINOR OUT_PATCH OUT_BUILD OUT_HA
EndIf ( )

# Find the latest git tag
GitExecute ( "git -C ${GIT_ROOT} describe --tags --abbrev=1 --match v[0-9].[0-9]* HEAD" False TAG SUCCESS )
GitExecute ( "${GIT_ROOT}" "git describe --tags --abbrev=1 --match v[0-9].[0-9]* HEAD" False TAG SUCCESS )
If ( NOT ${SUCCESS} )
Return ( )
EndIf ( )

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

GitExecute ( "git -C ${GIT_ROOT} rev-parse HEAD" True HASH SUCCESS )
GitExecute ( "${GIT_ROOT}" "git rev-parse HEAD" True HASH SUCCESS )
If ( NOT ${SUCCESS} )
Return ( )
EndIf ( )
@@ -108,7 +110,7 @@ Function ( GitGetHash GIT_ROOT OUT_HASH )
Message ( FATAL_ERROR "${GIT_ROOT} is not a git directory" )
EndIf ( )

GitExecute ( "git -C ${GIT_ROOT} rev-parse HEAD" True HASH SUCCESS )
GitExecute ( "${GIT_ROOT}" "git rev-parse HEAD" True HASH SUCCESS )
If ( NOT ${SUCCESS} )
Return ( )
EndIf ( )
@@ -126,7 +128,7 @@ Function ( GitGetIsDirty GIT_ROOT OUT_DIRTY )
Message ( FATAL_ERROR "${GIT_ROOT} is not a git directory" )
EndIf ( )

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


Loading…
Cancel
Save