From 5f3ac04b1e0c9bf58ea858ac3c980b6cf3d7ea6f Mon Sep 17 00:00:00 2001 From: Juan Escudero Date: Mon, 7 Oct 2024 00:31:32 +0000 Subject: [PATCH] git commands will not be available in non editable installs --- iop4api/views/index.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/iop4api/views/index.py b/iop4api/views/index.py index 60d050ad..5ceb139a 100644 --- a/iop4api/views/index.py +++ b/iop4api/views/index.py @@ -21,9 +21,15 @@ import logging logger = logging.getLogger(__name__) -GIT_COMMIT_HASH = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=os.path.dirname(os.path.realpath(__file__))).decode('ascii').strip() -GIT_BRANCH = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], cwd=os.path.dirname(os.path.realpath(__file__))).decode('ascii').strip() -GIT_DESCRIBE = subprocess.check_output(['git', 'describe', '--always'], cwd=os.path.dirname(os.path.realpath(__file__))).decode('ascii').strip() +try: + GIT_COMMIT_HASH = subprocess.check_output(['git', 'rev-parse', 'HEAD'], cwd=os.path.dirname(os.path.realpath(__file__))).decode('ascii').strip() + GIT_BRANCH = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD'], cwd=os.path.dirname(os.path.realpath(__file__))).decode('ascii').strip() + GIT_DESCRIBE = subprocess.check_output(['git', 'describe', '--always'], cwd=os.path.dirname(os.path.realpath(__file__))).decode('ascii').strip() +except Exception as e: + logger.error(f"Error getting git info: {e}") + GIT_COMMIT_HASH = "Unknown" + GIT_BRANCH = "Unknown" + GIT_DESCRIBE = "Unknown" def index(request, tabs=None):