Merge pull request #137 from felixonmars/pagure

Add support for Pagure
This commit is contained in:
依云 2020-09-01 18:28:42 +08:00 committed by GitHub
commit ade7d53a1a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 74 additions and 0 deletions

View file

@ -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,22 @@ 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.
This source returns tags and supports `list options`_.
Manually updating
-----------------
::

View file

@ -0,0 +1,28 @@
# 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: 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

29
tests/test_pagure.py Normal file
View file

@ -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"