Make ExtInfo.version optional instead of special casing an empty version

In case the version is an empty string it is considered newer by pacman
than for example "r123".

Instead make it optional and handle the None version everywhere.

Fixes #68
This commit is contained in:
Christoph Reiter 2024-03-26 13:39:47 +01:00
parent b2462470bc
commit 3c569263fd
3 changed files with 11 additions and 6 deletions

View File

@ -306,7 +306,7 @@ async def outofdate(request: Request, response: Response) -> list[OutOfDateEntry
git_version = extract_upstream_version(s.git_version)
info = s.upstream_info
if info is not None and info.version != "":
if info is not None and info.version is not None:
if version_is_newer_than(info.version, git_version):
to_update.append(OutOfDateEntry(
name=s.name,

View File

@ -32,7 +32,7 @@ class ExtId(NamedTuple):
class ExtInfo(NamedTuple):
name: str
version: str
version: str | None
date: int
url: str
other_urls: dict[str, str]
@ -495,6 +495,8 @@ class Source:
newest = None
fallback = None
for ext_id, info in self.external_infos:
if info.version is None:
continue
if ext_id.fallback:
if fallback is None or version_is_newer_than(info.version, fallback.version):
fallback = info
@ -504,9 +506,10 @@ class Source:
return newest or fallback or None
@property
def upstream_version(self) -> str:
def upstream_version(self) -> str | None:
"""None of no version is available"""
upstream_info = self.upstream_info
return upstream_info.version if upstream_info is not None else ""
return upstream_info.version if upstream_info is not None else None
@property
def pkgextra(self) -> PkgExtraEntry:
@ -546,13 +549,15 @@ class Source:
repology_repo = "msys2_msys2" if self._package.repo == "msys" else "msys2_mingw"
ext.append((
ExtId("repology", "Repology", True),
ExtInfo(self.realname, "", 0,
ExtInfo(self.realname, None, 0,
f"https://repology.org/tools/project-by?repo={quote(repology_repo)}&name_type=srcname&target_page=project_versions&name={quote(self.name)}", {})))
return sorted(ext)
@property
def is_outdated(self) -> bool:
if self.upstream_version is None:
return False
msys_version = extract_upstream_version(self.version)
return version_is_newer_than(self.upstream_version, msys_version)

View File

@ -456,7 +456,7 @@ async def outofdate(request: Request, response: Response, related: str | None =
git_version = ""
info = s.upstream_info
if info is not None and info.version != "":
if info is not None and info.version is not None:
if version_is_newer_than(info.version, msys_version):
to_update.append((s, msys_version, git_version, info.version, info.url, info.date))
else: