From 25bcf2c438232631bf5dd3c7c8c997a4edabc0f4 Mon Sep 17 00:00:00 2001 From: Matthias Date: Sun, 13 Feb 2022 23:49:59 +0100 Subject: [PATCH] make git log call simpler --- InvenTree/plugin/helpers.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/InvenTree/plugin/helpers.py b/InvenTree/plugin/helpers.py index ddccf8ed2d..6cc649c40b 100644 --- a/InvenTree/plugin/helpers.py +++ b/InvenTree/plugin/helpers.py @@ -98,14 +98,16 @@ def get_git_log(path): """ path = path.replace(os.path.dirname(settings.BASE_DIR), '')[1:] command = ['git', 'log', '-n', '1', "--pretty=format:'%H%n%aN%n%aE%n%aI%n%f%n%G?%n%GK'", '--follow', '--', path] + output = None try: output = str(subprocess.check_output(command, cwd=os.path.dirname(settings.BASE_DIR)), 'utf-8')[1:-1] if output: output = output.split('\n') - else: - output = 7 * [''] - except subprocess.CalledProcessError: - output = 7 * [''] + except subprocess.CalledProcessError: # pragma: no cover + pass + + if not output: + output = 7 * [''] # pragma: no cover return {'hash': output[0], 'author': output[1], 'mail': output[2], 'date': output[3], 'message': output[4], 'verified': output[5], 'key': output[6]}