From d51c82a68c39b122541355699eb0a48c4c52ce5c Mon Sep 17 00:00:00 2001 From: Alfredo Monclus Date: Fri, 7 Jun 2024 15:40:34 -0300 Subject: [PATCH] functions: log the version without the extra letter --- ks_includes/functions.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/ks_includes/functions.py b/ks_includes/functions.py index 8a739b08..aa97f102 100644 --- a/ks_includes/functions.py +++ b/ks_includes/functions.py @@ -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 "?"