mirror of
https://github.com/dw-0/kiauh.git
synced 2026-05-08 10:18:18 +05:00
fix(core): standardize handling of None values for repo and version fields
- Improve local and remote version comparison by replacing default placeholders with None. - Update repo and branch logic to handle None values consistently. - Refactor type hints for better readability and accuracy.
This commit is contained in:
@@ -95,8 +95,8 @@ class MainMenu(BaseMenu):
|
||||
status_data: ComponentStatus = status_fn(*args)
|
||||
code: int = status_data.status
|
||||
status: StatusText = StatusMap[code]
|
||||
owner: str = trunc_string(status_data.owner, 23)
|
||||
repo: str = trunc_string(status_data.repo, 23)
|
||||
owner: str = trunc_string(status_data.owner, 23) if status_data.owner else '-'
|
||||
repo: str = trunc_string(status_data.repo, 23) if status_data.repo else '-'
|
||||
instance_count: int = status_data.instances
|
||||
|
||||
count_txt: str = ""
|
||||
|
||||
@@ -257,7 +257,7 @@ class UpdateMenu(BaseMenu):
|
||||
|
||||
def _format_local_status(self, local_version, remote_version) -> str:
|
||||
color = Color.RED
|
||||
if not local_version or local_version == '-':
|
||||
if local_version is None:
|
||||
color = Color.RED
|
||||
elif local_version == remote_version:
|
||||
color = Color.GREEN
|
||||
@@ -290,7 +290,13 @@ class UpdateMenu(BaseMenu):
|
||||
return self.status_data[name]["installed"]
|
||||
|
||||
def _is_update_available(self, name: str) -> bool:
|
||||
return self.status_data[name]["local"] != self.status_data[name]["remote"]
|
||||
local = self.status_data[name]["local"]
|
||||
remote = self.status_data[name]["remote"]
|
||||
|
||||
if local is None or remote is None:
|
||||
return False
|
||||
|
||||
return local != remote
|
||||
|
||||
def _run_update_routine(self, name: str, update_fn: Callable, *args) -> None:
|
||||
display_name = self.status_data[name]["display_name"]
|
||||
|
||||
@@ -26,7 +26,7 @@ class ComponentStatus:
|
||||
owner: str | None = None
|
||||
repo: str | None = None
|
||||
repo_url: str | None = None
|
||||
branch: str = ""
|
||||
branch: str | None = None
|
||||
local: str | None = None
|
||||
remote: str | None = None
|
||||
instances: int | None = None
|
||||
|
||||
Reference in New Issue
Block a user