better updater

This commit is contained in:
N0\A
2025-10-24 12:00:19 +02:00
parent b21c122415
commit 9d690fb135
2 changed files with 25 additions and 12 deletions

View File

@@ -3,6 +3,24 @@ from pathlib import Path
REPO_DIR = Path(__file__).parent.parent
def is_update_available():
try:
if not (REPO_DIR / ".git").exists():
return False
repo = Repo(REPO_DIR)
origin = repo.remotes.origin
origin.fetch()
local_commit = repo.head.commit
remote_commit = origin.refs[repo.active_branch.name].commit
return local_commit != remote_commit
except GitCommandError:
return False
except Exception:
return False
def update_repository():
try:
if not (REPO_DIR / ".git").exists():
@@ -11,14 +29,6 @@ def update_repository():
repo = Repo(REPO_DIR)
origin = repo.remotes.origin
origin.fetch()
local_commit = repo.head.commit
remote_commit = origin.refs[repo.active_branch.name].commit
if local_commit == remote_commit:
return "UP_TO_DATE", "You are already on the latest version."
origin.pull()
return "UPDATED", "CLARA has been updated successfully."