diff --git a/zynconf/zynthian_config.py b/zynconf/zynthian_config.py index 3f9b8c4ae..39c85b3d4 100755 --- a/zynconf/zynthian_config.py +++ b/zynconf/zynthian_config.py @@ -172,6 +172,10 @@ config_fpath = config_dir + "/zynthian_envars.sh" zynthian_repositories = ["zynthian-sys", "zynthian-ui", "zyncoder", "zynthian-data", "zynthian-webconf"] +stable_branch = "oram" +stable_tag = "oram-2409" +testing_branch = "vangelis" + # ------------------------------------------------------------------------------- # Version configuration # ------------------------------------------------------------------------------- @@ -200,10 +204,10 @@ def get_git_tag(path): except: return None -def get_git_local_hash(path): +def get_git_local_hash(path, branch): # Get the hash of the current commit for a git branch or None if invalid try: - return check_output(f"git -C {path} rev-parse HEAD", + return check_output(f"git -C {path} rev-parse {branch}", encoding="utf-8", shell=True).strip() except: return None @@ -220,11 +224,24 @@ def get_git_remote_hash(path, branch=None): except: return None +def update_available(path, refresh): + if refresh: + update_git(path) + branch = get_git_branch(path) + if branch is None: + branch = get_git_tag(path) + local_hash = get_git_local_hash(path, branch) + remote_hash = get_git_remote_hash(path, branch) + return local_hash != remote_hash + def get_git_version_info(path): # Get version information about a git repository - local_hash = get_git_local_hash(path) branch = get_git_branch(path) tag = get_git_tag(path) + if branch: + local_hash = get_git_local_hash(path, branch) + else: + local_hash = get_git_local_hash(path, tag) release_name = None version = None major_version = 0 @@ -239,7 +256,10 @@ def get_git_version_info(path): version = parts[1] if version: parts = version.split(".", 3) - major_version = parts[0] + try: + major_version = int(parts[0]) + except: + pass if len(parts) > 2: patch_version = parts[2] if len(parts) > 1: @@ -254,7 +274,6 @@ def get_git_version_info(path): continue v_parts = parts[1].split(".", 3) try: - major_version = int(major_version) x = int(v_parts[0]) y = z = 0 if len(v_parts) > 1: @@ -272,10 +291,19 @@ def get_git_version_info(path): patch_version = z except: pass + if tag: + if tag == stable_tag: + display_name = f"{tag}.{minor_version}.{patch_version}" + else: + display_name = tag + else: + display_name = branch + result = { "branch": branch, "tag": tag, "name": release_name, + "display_name": display_name, "major": major_version, "minor": minor_version, "patch": patch_version, diff --git a/zyngine/zynthian_state_manager.py b/zyngine/zynthian_state_manager.py index a94009cdb..802c2420c 100644 --- a/zyngine/zynthian_state_manager.py +++ b/zyngine/zynthian_state_manager.py @@ -2733,11 +2733,7 @@ def update_thread(): # If attached to last stable => Detect if new tag relase available for repo in zynconf.zynthian_repositories: path = f"/zynthian/{repo}" - zynconf.update_git(path) - local_hash = zynconf.get_git_local_hash(path) - remote_hash = zynconf.get_git_remote_hash(path, "HEAD") - #logging.debug(f"*********** BRANCH {branch} => local hash {local_hash}, remote hash {remote_hash} ****************") - if local_hash != remote_hash: + if zynconf.update_available(path, True): self.update_available = True break except Exception as e: