From 7fff0a74276ad2b71288f4edb919407f9b7bb982 Mon Sep 17 00:00:00 2001 From: Oliver Walters Date: Fri, 1 May 2020 17:02:11 +1000 Subject: [PATCH] Catch an error if git cannot be found --- InvenTree/InvenTree/version.py | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/InvenTree/InvenTree/version.py b/InvenTree/InvenTree/version.py index 3ac225fd6e..e76123c6d8 100644 --- a/InvenTree/InvenTree/version.py +++ b/InvenTree/InvenTree/version.py @@ -27,12 +27,17 @@ def inventreeDjangoVersion(): def inventreeCommitHash(): """ Returns the git commit hash for the running codebase """ - return str(subprocess.check_output('git rev-parse --short HEAD'.split()), 'utf-8').strip() + try: + return str(subprocess.check_output('git rev-parse --short HEAD'.split()), 'utf-8').strip() + except FileNotFoundError: + return None def inventreeCommitDate(): """ Returns the git commit date for the running codebase """ - d = str(subprocess.check_output('git show -s --format=%ci'.split()), 'utf-8').strip() - - return d.split(' ')[0] + try: + d = str(subprocess.check_output('git show -s --format=%ci'.split()), 'utf-8').strip() + return d.split(' ')[0] + except FileNotFoundError: + return None