Skip to content

Commit

Permalink
git commands will not be available in non editable installs
Browse files Browse the repository at this point in the history
  • Loading branch information
juanep97 authored and morcuended committed Oct 22, 2024
1 parent b7016d3 commit 5f3ac04
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions iop4api/views/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):

Expand Down

0 comments on commit 5f3ac04

Please sign in to comment.