mirror of
https://github.com/EDCD/EDMarketConnector.git
synced 2025-04-19 10:27:38 +03:00
parent
0b9991b092
commit
924221f063
14
config.py
14
config.py
@ -96,9 +96,21 @@ def git_shorthash_from_head() -> str:
|
||||
"""
|
||||
Determine short hash for current git HEAD.
|
||||
|
||||
Includes -DIRTY if any changes have been made from HEAD
|
||||
|
||||
:return: str - None if we couldn't determine the short hash.
|
||||
"""
|
||||
shorthash: str = None # type: ignore
|
||||
dirty = False
|
||||
|
||||
with contextlib.suppress(Exception):
|
||||
result = subprocess.run('git diff --stat HEAD'.split(), capture_output=True)
|
||||
if len(result.stdout) > 0:
|
||||
dirty = True
|
||||
|
||||
if len(result.stderr) > 0:
|
||||
logger.warning(f'Data from git on stderr:\n{str(result.stderr)}')
|
||||
|
||||
try:
|
||||
git_cmd = subprocess.Popen('git rev-parse --short HEAD'.split(),
|
||||
stdout=subprocess.PIPE,
|
||||
@ -115,7 +127,7 @@ def git_shorthash_from_head() -> str:
|
||||
logger.error(f"'{shorthash}' doesn't look like a valid git short hash, forcing to None")
|
||||
shorthash = None # type: ignore
|
||||
|
||||
return shorthash
|
||||
return shorthash + ('-WORKING-DIR-IS-DIRTY' if dirty else '')
|
||||
|
||||
|
||||
def appversion() -> semantic_version.Version:
|
||||
|
Loading…
x
Reference in New Issue
Block a user