fix(update): 镜像版本无法解析时不提供任何更新(Codex 审查)

This commit is contained in:
Estrella Pan
2026-10-24 11:09:21 +02:00
parent 29dc558789
commit f84e31d8e0
2 changed files with 11 additions and 1 deletions

View File

@@ -217,6 +217,7 @@ class Updater:
async def _fetch_releases(self) -> list[dict]:
client = await self._get_client()
# ponytail: 只取第一页;之后的 4.x 发布超过 100 个时,再按页往后找 3.x
url = f"{_API_BASE}/repos/{self.owner}/{self.repo}/releases?per_page=100"
resp = await client.get(url, headers=_API_HEADERS)
resp.raise_for_status()
@@ -281,7 +282,8 @@ class Updater:
ver = _parse_semver(rel.get("tag_name") or "")
if ver is None:
continue
if image is not None and ver.major != image.major:
# 镜像版本无法解析(开发/本地构建)时 _image_supports 拒绝任何更新包
if image is None or ver.major != image.major:
continue
candidates.append((ver, rel))
if not candidates:

View File

@@ -249,6 +249,14 @@ class TestCheckUpdate:
assert picked is not None
assert picked["tag_name"] == expected
def test_unparseable_image_version_is_offered_nothing(self, tmp_path):
"""开发/本地构建不能应用更新包,也不应提示有更新。"""
releases = [{"tag_name": "3.3.7", "prerelease": False}]
up = Updater(
root=tmp_path / "u", current_version="3.3.6", image_version="DEV_VERSION"
)
assert up._pick_release(releases, "stable") is None
@pytest.mark.asyncio
async def test_no_update_when_current_is_latest(self, tmp_path, bundle):
data, sha = bundle