Catch an error if git cannot be found

This commit is contained in:
Oliver Walters 2020-05-01 17:02:11 +10:00
parent 68bbb372dc
commit 7fff0a7427

View File

@ -27,12 +27,17 @@ def inventreeDjangoVersion():
def inventreeCommitHash(): def inventreeCommitHash():
""" Returns the git commit hash for the running codebase """ """ Returns the git commit hash for the running codebase """
try:
return str(subprocess.check_output('git rev-parse --short HEAD'.split()), 'utf-8').strip() return str(subprocess.check_output('git rev-parse --short HEAD'.split()), 'utf-8').strip()
except FileNotFoundError:
return None
def inventreeCommitDate(): def inventreeCommitDate():
""" Returns the git commit date for the running codebase """ """ Returns the git commit date for the running codebase """
try:
d = str(subprocess.check_output('git show -s --format=%ci'.split()), 'utf-8').strip() d = str(subprocess.check_output('git show -s --format=%ci'.split()), 'utf-8').strip()
return d.split(' ')[0] return d.split(' ')[0]
except FileNotFoundError:
return None