Browse Source

* Added git helper to check for uncommitted changes

master
Klaus Nöske 4 years ago
parent
commit
a607190e4f
1 changed files with 21 additions and 0 deletions
  1. +21
    -0
      cmake/git_helper.cmake

+ 21
- 0
cmake/git_helper.cmake View File

@@ -118,3 +118,24 @@ Function ( GitGetHash GIT_ROOT OUT_HASH )
Set ( ${OUT_HASH} ${HASH} PARENT_SCOPE )

EndFunction ( )

# Checks if the given git repository has uncommitted changes
Function ( GitGetIsDirty GIT_ROOT OUT_DIRTY )

If ( NOT EXISTS "${GIT_ROOT}/.git" )
Return ( )
EndIf ( )

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

# dirty
If ( DIRTY )
Set ( ${OUT_DIRTY} 1 PARENT_SCOPE )
Else ( )
Set ( ${OUT_DIRTY} 0 PARENT_SCOPE )
EndIf ( )

EndFunction ( )

Loading…
Cancel
Save