Merge remote-tracking branch 'origin/pr/276'

This commit is contained in:
lilydjwg 2024-08-08 23:41:52 +08:00
commit 3abe5ad394
3 changed files with 15 additions and 1 deletions

View File

@ -757,6 +757,11 @@ This enables you to track updates from `Anitya <https://release-monitoring.org/>
anitya anitya
``distro/package``, where ``distro`` can be a lot of things like "fedora", "arch linux", "gentoo", etc. ``package`` is the package name of the chosen distribution. ``distro/package``, where ``distro`` can be a lot of things like "fedora", "arch linux", "gentoo", etc. ``package`` is the package name of the chosen distribution.
anitya_id
The identifier of the project/package in anitya.
Note that either anitya or anitya_id needs to be specified, anitya_id is preferred when both specified.
Check Android SDK Check Android SDK
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~
:: ::

View File

@ -6,7 +6,9 @@ from nvchecker.api import RichResult
URL = 'https://release-monitoring.org/api/project/{pkg}' URL = 'https://release-monitoring.org/api/project/{pkg}'
async def get_version(name, conf, *, cache, **kwargs): async def get_version(name, conf, *, cache, **kwargs):
pkg = conf.get('anitya') pkg = conf.get('anitya_id')
if pkg is None:
pkg = conf.get('anitya')
url = URL.format(pkg = pkg) url = URL.format(pkg = pkg)
data = await cache.get_json(url) data = await cache.get_json(url)
return RichResult( return RichResult(

View File

@ -13,3 +13,10 @@ async def test_anitya(get_version):
"anitya": "fedora/shutter", "anitya": "fedora/shutter",
}) })
assert re.match(r"[0-9.]+", version) assert re.match(r"[0-9.]+", version)
async def test_anitya_by_id(get_version):
version = await get_version("shutter", {
"source": "anitya",
"anitya_id": "4813",
})
assert re.match(r"[0-9.]+", version)