Skip to content

Commit

Permalink
Fix check for updates
Browse files Browse the repository at this point in the history
  • Loading branch information
riban committed Dec 26, 2024
1 parent 3cd0915 commit f1ace9b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 10 deletions.
25 changes: 20 additions & 5 deletions zynconf/zynthian_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,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 @@ -224,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 @@ -243,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 @@ -258,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 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 f1ace9b

Please sign in to comment.