add second search of packages version, if package is older than branch

This commit is contained in:
Nadezhda Fedorova 2024-12-16 14:55:37 +03:00 committed by Надежда Краснобородько
parent cb5f3ec98f
commit 78daf7d9bb

View File

@ -92,6 +92,19 @@ def api_get_source_package_version(branch: str, package_name: str) -> str:
response = requests.get(api_url, params)
if response.status_code != 200:
print(response)
api_url = "https://rdb.altlinux.org/api/site/package_versions"
params = {"arch": "x86_64", "package_type": "source", "name": package_name}
response = requests.get(api_url, params)
if response.status_code != 200:
print(response)
raise RuntimeError(
f"failed to retrieve source package version: source package {package_name!r}, branch {branch!r} "
)
result = response.json()
for v in result["versions"]:
if v["branch"] == branch:
return v["version"]
raise RuntimeError(
f"failed to retrieve source package version: source package {package_name!r}, branch {branch!r} "
)