mirror of
https://github.com/lilydjwg/nvchecker
synced 2025-02-04 04:21:43 +00:00
Add a git source
It's a thin wrapper around the cmd source, and reuses its get_cmd function.
This commit is contained in:
parent
a78c06163c
commit
c9b689d67b
@ -641,6 +641,19 @@ strip_release
|
|||||||
|
|
||||||
Note that either pkg or srcpkg needs to be specified (but not both) or the item name will be used as pkg.
|
Note that either pkg or srcpkg needs to be specified (but not both) or the item name will be used as pkg.
|
||||||
|
|
||||||
|
Check Git repository
|
||||||
|
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||||
|
::
|
||||||
|
|
||||||
|
source = "git"
|
||||||
|
|
||||||
|
This enables you to check tags of an arbitrary git repository, also useful for scenarios like a github project having too many tags.
|
||||||
|
|
||||||
|
url
|
||||||
|
URL of the Git repository.
|
||||||
|
|
||||||
|
This source returns tags and supports :ref:`list options`.
|
||||||
|
|
||||||
Manually updating
|
Manually updating
|
||||||
~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~
|
||||||
::
|
::
|
||||||
|
15
nvchecker_source/git.py
Normal file
15
nvchecker_source/git.py
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
# MIT licensed
|
||||||
|
# Copyright (c) 2020 Felix Yan <felixonmars@archlinux.org>, et al.
|
||||||
|
|
||||||
|
import re
|
||||||
|
from nvchecker_source.cmd import run_cmd
|
||||||
|
|
||||||
|
async def get_version(
|
||||||
|
name, conf, *, cache, keymanager=None
|
||||||
|
):
|
||||||
|
git = conf['git']
|
||||||
|
cmd = f"git ls-remote -t --refs {git}"
|
||||||
|
data = await cache.get(cmd, run_cmd)
|
||||||
|
regex = "(?<=refs/tags/).*$"
|
||||||
|
|
||||||
|
return re.findall(regex, data)
|
11
tests/test_git.py
Normal file
11
tests/test_git.py
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
# 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_git(get_version):
|
||||||
|
assert await get_version("example", {
|
||||||
|
"source": "git",
|
||||||
|
"git": "https://gitlab.com/gitlab-org/gitlab-test.git",
|
||||||
|
}) == "v1.1.1"
|
Loading…
Reference in New Issue
Block a user