Skip to content

Commit

Permalink
Merge pull request #510 from riban-bw/vangelis
Browse files Browse the repository at this point in the history
Software update fixes.
  • Loading branch information
riban-bw authored Dec 26, 2024
2 parents d27d984 + e25d1c3 commit c962e2a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 10 deletions.
38 changes: 33 additions & 5 deletions zynconf/zynthian_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
# -------------------------------------------------------------------------------
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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:
Expand All @@ -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:
Expand All @@ -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,
Expand Down
6 changes: 1 addition & 5 deletions zyngine/zynthian_state_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit c962e2a

Please sign in to comment.