Add support for Pagure
This commit is contained in:
parent
0cfaac774d
commit
a7da4207ae
15
README.rst
15
README.rst
|
@ -56,6 +56,7 @@ Contents
|
|||
* `Check Anitya (release-monitoring.org) <#check-anitya>`_
|
||||
* `Check Android SDK <#check-android-sdk>`_
|
||||
* `Check Sparkle framework <#check-sparkle-framework>`_
|
||||
* `Check Pagure <#check-pagure>`_
|
||||
* `Manually updating <#manually-updating>`_
|
||||
* `Extending <#extending>`_
|
||||
|
||||
|
@ -633,6 +634,20 @@ This enables you to track updates of macOS applications which using `Sparkle fra
|
|||
sparkle
|
||||
The url of the sparkle appcast.
|
||||
|
||||
Check Pagure
|
||||
------------
|
||||
::
|
||||
|
||||
source = "pagure"
|
||||
|
||||
This enables you to check updates from `Pagure <https://pagure.io>`_.
|
||||
|
||||
pagure
|
||||
The project name, optionally with a namespace.
|
||||
|
||||
host
|
||||
Hostname of alternative instance like src.fedoraproject.org.
|
||||
|
||||
Manually updating
|
||||
-----------------
|
||||
::
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
# MIT licensed
|
||||
# Copyright (c) 2020 Felix Yan <felixonmars@archlinux.org>, et al.
|
||||
|
||||
import urllib.parse
|
||||
|
||||
import structlog
|
||||
|
||||
from nvchecker.api import (
|
||||
VersionResult, Entry, AsyncCache, KeyManager,
|
||||
)
|
||||
|
||||
PAGURE_URL = 'https://%s/api/0/%s/git/tags'
|
||||
|
||||
logger = structlog.get_logger(logger_name=__name__)
|
||||
|
||||
async def get_version(name, conf, **kwargs):
|
||||
return await get_version_real(name, conf, **kwargs)
|
||||
|
||||
async def get_version_real(
|
||||
name: str, conf: Entry, *,
|
||||
cache: AsyncCache, keymanager: KeyManager,
|
||||
**kwargs,
|
||||
) -> VersionResult:
|
||||
repo = conf['pagure']
|
||||
host = conf.get('host', "pagure.io")
|
||||
|
||||
url = PAGURE_URL % (host, repo)
|
||||
|
||||
data = await cache.get_json(url)
|
||||
version = data["tags"]
|
||||
return version
|
|
@ -0,0 +1,29 @@
|
|||
# MIT licensed
|
||||
# Copyright (c) 2020 Felix Yan <felixonmars@archlinux.org>, et al.
|
||||
|
||||
import pytest
|
||||
pytestmark = [pytest.mark.asyncio, pytest.mark.needs_net]
|
||||
|
||||
async def test_pagure(get_version):
|
||||
ver = await get_version("example", {
|
||||
"source": "pagure",
|
||||
"pagure": "nvchecker-test",
|
||||
})
|
||||
assert ver == "0.2"
|
||||
|
||||
async def test_pagure_with_ignored(get_version):
|
||||
ver = await get_version("example", {
|
||||
"source": "pagure",
|
||||
"pagure": "nvchecker-test",
|
||||
"ignored": "0.2",
|
||||
})
|
||||
assert ver == "0.1"
|
||||
|
||||
async def test_pagure_with_alternative_host(get_version):
|
||||
ver = await get_version("example", {
|
||||
"source": "pagure",
|
||||
"pagure": "rpms/glibc",
|
||||
"host": "src.fedoraproject.org",
|
||||
"include_regex": r"F-\d+-start",
|
||||
})
|
||||
assert ver == "F-13-start"
|
Loading…
Reference in New Issue