feat: don't install pre-releases

This commit is contained in:
Matthias
2025-04-03 20:21:08 +02:00
parent 1aaf0c2034
commit 26c7752b7c
2 changed files with 30 additions and 8 deletions

View File

@@ -61,14 +61,18 @@ def get_ui_download_url(version: str | None = None) -> tuple[str, str]:
if version:
tmp = [x for x in r if x["name"] == version]
else:
tmp = [x for x in r if not x.get("prerelease")]
if tmp:
# Ensure we have the latest version
if version is None:
tmp.sort(key=lambda x: x["created_at"], reverse=True)
latest_version = tmp[0]["name"]
assets = tmp[0].get("assets", [])
else:
raise ValueError("UI-Version not found.")
else:
latest_version = r[0]["name"]
assets = r[0].get("assets", [])
dl_url = ""
if assets and len(assets) > 0:
dl_url = assets[0]["browser_download_url"]

View File

@@ -711,7 +711,21 @@ def test_get_ui_download_url(mocker):
response = MagicMock()
response.json = MagicMock(
side_effect=[
[{"assets_url": "http://whatever.json", "name": "0.0.1"}],
[
{
# Pre-release is ignored
"assets_url": "http://whatever.json",
"name": "0.0.2",
"created_at": "2024-02-01T00:00:00Z",
"prerelease": True,
},
{
"assets_url": "http://whatever.json",
"name": "0.0.1",
"created_at": "2024-01-01T00:00:00Z",
"prerelease": False,
},
],
[{"browser_download_url": "http://download.zip"}],
]
)
@@ -729,11 +743,15 @@ def test_get_ui_download_url_direct(mocker):
{
"assets_url": "http://whatever.json",
"name": "0.0.2",
"created_at": "2024-02-01T00:00:00Z",
"prerelease": False,
"assets": [{"browser_download_url": "http://download22.zip"}],
},
{
"assets_url": "http://whatever.json",
"name": "0.0.1",
"created_at": "2024-01-01T00:00:00Z",
"prerelease": False,
"assets": [{"browser_download_url": "http://download1.zip"}],
},
]