functions: log the version without the extra letter

This commit is contained in:
Alfredo Monclus
2024-06-07 15:40:34 -03:00
parent ccd8fd9fcc
commit d51c82a68c

View File

@@ -58,22 +58,25 @@ except Exception as e:
def get_software_version():
prog = ('git', '-C', os.path.dirname(__file__), 'describe', '--always',
'--tags', '--long', '--dirty')
prog = ('git', '-C', os.path.dirname(__file__), 'describe', '--always', '--tags', '--long', '--dirty')
try:
process = subprocess.Popen(prog, stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
process = subprocess.Popen(prog, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
ver, err = process.communicate()
retcode = process.wait()
if retcode == 0:
version = ver.strip()
if isinstance(version, bytes):
version = version.decode()
# Remove the 'g' at the start of the hash
parts = version.split('-')
if len(parts) > 2 and parts[-2].startswith('g'):
parts[-2] = parts[-2][1:] # Remove the 'g'
version = '-'.join(parts)
return version
else:
logging.debug(f"Error getting git version: {err}")
except OSError:
logging.exception("Error runing git describe")
logging.exception("Error running git describe")
return "?"