From 9df0eff4d2155665de08a564227b7b74cd2a149f Mon Sep 17 00:00:00 2001 From: Dramelac Date: Fri, 1 Mar 2024 13:33:21 +0100 Subject: [PATCH] Add current branch to the current version display --- exegol/manager/UpdateManager.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/exegol/manager/UpdateManager.py b/exegol/manager/UpdateManager.py index c90cb1de..e151c189 100644 --- a/exegol/manager/UpdateManager.py +++ b/exegol/manager/UpdateManager.py @@ -250,7 +250,7 @@ def __compareVersion(cls, version) -> bool: def __get_current_version(cls): """Get the current version of the exegol wrapper. Handle dev version and release stable version depending on the current version.""" current_version = ConstantConfig.version - if re.search(r'[a-z]', ConstantConfig.version, re.IGNORECASE): + if re.search(r'[a-z]', ConstantConfig.version, re.IGNORECASE) and ConstantConfig.git_source_installation: module = ExegolModules().getWrapperGit(fast_load=True) if module.isAvailable: current_version = str(module.get_current_commit())[:8] @@ -259,12 +259,19 @@ def __get_current_version(cls): @staticmethod def display_current_version(): """Get the current version of the exegol wrapper. Handle dev version and release stable version depending on the current version.""" - commit_version = "" - if re.search(r'[a-z]', ConstantConfig.version, re.IGNORECASE): + version_details = "" + if ConstantConfig.git_source_installation: module = ExegolModules().getWrapperGit(fast_load=True) if module.isAvailable: - commit_version = f" [bright_black]\\[{str(module.get_current_commit())[:8]}][/bright_black]" - return f"[blue]v{ConstantConfig.version}[/blue]{commit_version}" + current_branch = module.getCurrentBranch() + commit_version = "" + if re.search(r'[a-z]', ConstantConfig.version, re.IGNORECASE): + commit_version = "-" + str(module.get_current_commit())[:8] + if current_branch is None: + current_branch = "HEAD" + if current_branch != "master" or commit_version != "": + version_details = f" [bright_black]\\[{current_branch}{commit_version}][/bright_black]" + return f"[blue]v{ConstantConfig.version}[/blue]{version_details}" @classmethod def __tagUpdateAvailable(cls, latest_version, current_version=None):