2020-09-01 10:01:59 +00:00
|
|
|
# MIT licensed
|
|
|
|
# Copyright (c) 2020 Felix Yan <felixonmars@archlinux.org>, et al.
|
|
|
|
|
|
|
|
import urllib.parse
|
|
|
|
|
|
|
|
import structlog
|
|
|
|
|
|
|
|
from nvchecker.api import (
|
2023-10-18 00:00:46 +00:00
|
|
|
VersionResult, RichResult, Entry, AsyncCache, KeyManager,
|
2020-09-01 10:01:59 +00:00
|
|
|
)
|
|
|
|
|
2023-10-18 00:00:46 +00:00
|
|
|
PAGURE_URL = 'https://%s/api/0/%s/git/tags?with_commits=true'
|
2020-09-01 10:01:59 +00:00
|
|
|
|
|
|
|
logger = structlog.get_logger(logger_name=__name__)
|
|
|
|
|
2020-09-01 10:13:56 +00:00
|
|
|
async def get_version(
|
2020-09-01 10:01:59 +00:00
|
|
|
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)
|
2023-10-18 00:00:46 +00:00
|
|
|
return [
|
|
|
|
RichResult(
|
|
|
|
version = version,
|
|
|
|
url = f'https://{host}/{repo}/tree/{version_hash}',
|
|
|
|
) for version, version_hash in data["tags"].items()
|
|
|
|
]
|