only fetch commit hash if in running from git repo

This commit is contained in:
Izalia Mae 2022-11-16 10:41:00 -05:00
parent 8fd712c849
commit ef5d4bc579
2 changed files with 11 additions and 6 deletions

View file

@ -1,4 +1,4 @@
from .manage import main from relay.manage import main
if __name__ == '__main__': if __name__ == '__main__':

View file

@ -2,6 +2,8 @@ import logging
import subprocess import subprocess
import traceback import traceback
from pathlib import Path
from . import __version__, misc from . import __version__, misc
from .http_debug import STATS from .http_debug import STATS
from .misc import Message, Response, WKNodeinfo from .misc import Message, Response, WKNodeinfo
@ -9,13 +11,16 @@ from .processors import run_processor
routes = [] routes = []
version = __version__
try:
if Path(__file__).parent.parent.joinpath('.git').exists():
try:
commit_label = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip().decode('ascii') commit_label = subprocess.check_output(["git", "rev-parse", "HEAD"]).strip().decode('ascii')
version = f'{__version__} {commit_label}' version = f'{__version__} {commit_label}'
except: except:
version = __version__ pass
def register_route(method, path): def register_route(method, path):