Browse Source

Fixed issue getting commit hash

master^2
TGRCDev 4 months ago
parent
commit
72be9521c5
No known key found for this signature in database GPG Key ID: 3A975199085322C3
1 changed files with 12 additions and 6 deletions
  1. +12
    -6
      __init__.py

+ 12
- 6
__init__.py View File

@ -118,12 +118,19 @@ def create_app():
def fetch_and_store_commit_hash():
f = open(commit_hash_filename, "w")
import subprocess
args = ['--git-dir=' + os.path.join(os.path.abspath(os.path.dirname(__file__)), ".git"), 'rev-parse', '--short', 'HEAD']
try:
commit_hash = subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode("utf-8").strip()
f.write(commit_hash)
f.close()
return commit_hash
except subprocess.CalledProcessError:
try:
commit_hash = subprocess.check_output(['git'] + args).decode("utf-8").strip()
f.write(commit_hash)
f.close()
return commit_hash
except:
commit_hash = subprocess.check_output(['/usr/bin/git'] + args).decode("utf-8").strip()
f.write(commit_hash)
f.close()
return commit_hash
except:
return ""
@app.before_first_request
@ -134,7 +141,6 @@ def create_app():
try:
f = open(commit_hash_filename, "r")
hash = f.read()
print(hash)
return hash
except Exception:
traceback.print_exc()


Loading…
Cancel
Save