git revision log: Catch cases where the git repo is not present.
@@ -17,14 +17,18 @@ def is_number(s, number_type):
# from https://stackoverflow.com/questions/14989858/get-the-current-git-hash-in-a-python-script
def get_git_revision_hash():
+ try:
if which('git') is not None:
with Path(kge_base_dir()):
return subprocess.check_output(["git", "rev-parse", "HEAD"]).strip().decode()
else:
- return 'no git binary found'
+ return 'No git binary found'
+ except:
+ return 'No working git repository found.'
# from https://stackoverflow.com/questions/14989858/get-the-current-git-hash-in-a-python-script
def get_git_revision_short_hash():
+ try:
if which('git') is not None:
with Path(kge_base_dir()):
return (
@@ -33,7 +37,9 @@ def get_git_revision_short_hash():
.decode()
)
else:
- return 'no git binary found'
+ return 'No git binary found'
+ except:
+ return 'No working git repository found.'
# from https://stackoverflow.com/questions/377017/test-if-executable-exists-in-python
def which(program):
