mirror of
https://github.com/EstrellaXD/Auto_Bangumi.git
synced 2026-11-03 06:04:20 +08:00
fix(update): 镜像版本无法解析时不提供任何更新(Codex 审查)
This commit is contained in:
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user