mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
gitlab: omit default branch if not specified, fix for blm
This commit is contained in:
parent
968af3df0b
commit
f8f261c476
2 changed files with 14 additions and 3 deletions
|
@ -10,7 +10,7 @@ from nvchecker.api import (
|
||||||
TemporaryError,
|
TemporaryError,
|
||||||
)
|
)
|
||||||
|
|
||||||
GITLAB_URL = 'https://%s/api/v4/projects/%s/repository/commits?ref_name=%s'
|
GITLAB_URL = 'https://%s/api/v4/projects/%s/repository/commits'
|
||||||
GITLAB_MAX_TAG = 'https://%s/api/v4/projects/%s/repository/tags'
|
GITLAB_MAX_TAG = 'https://%s/api/v4/projects/%s/repository/tags'
|
||||||
|
|
||||||
logger = structlog.get_logger(logger_name=__name__)
|
logger = structlog.get_logger(logger_name=__name__)
|
||||||
|
@ -27,14 +27,16 @@ async def get_version_real(
|
||||||
**kwargs,
|
**kwargs,
|
||||||
) -> VersionResult:
|
) -> VersionResult:
|
||||||
repo = urllib.parse.quote_plus(conf['gitlab'])
|
repo = urllib.parse.quote_plus(conf['gitlab'])
|
||||||
br = conf.get('branch', 'master')
|
br = conf.get('branch')
|
||||||
host = conf.get('host', "gitlab.com")
|
host = conf.get('host', "gitlab.com")
|
||||||
use_max_tag = conf.get('use_max_tag', False)
|
use_max_tag = conf.get('use_max_tag', False)
|
||||||
|
|
||||||
if use_max_tag:
|
if use_max_tag:
|
||||||
url = GITLAB_MAX_TAG % (host, repo)
|
url = GITLAB_MAX_TAG % (host, repo)
|
||||||
else:
|
else:
|
||||||
url = GITLAB_URL % (host, repo, br)
|
url = GITLAB_URL % (host, repo)
|
||||||
|
if br:
|
||||||
|
url += '?ref_name=%s' % br
|
||||||
|
|
||||||
# Load token from config
|
# Load token from config
|
||||||
token = conf.get('token')
|
token = conf.get('token')
|
||||||
|
|
|
@ -12,6 +12,15 @@ async def test_gitlab(get_version):
|
||||||
assert len(ver) == 8
|
assert len(ver) == 8
|
||||||
assert ver.isdigit()
|
assert ver.isdigit()
|
||||||
|
|
||||||
|
async def test_gitlab_blm(get_version):
|
||||||
|
# repo with a custom main branch
|
||||||
|
ver = await get_version("example", {
|
||||||
|
"source": "gitlab",
|
||||||
|
"gitlab": "asus-linux/asus-nb-ctrl",
|
||||||
|
})
|
||||||
|
assert len(ver) == 8
|
||||||
|
assert ver.isdigit()
|
||||||
|
|
||||||
async def test_gitlab_max_tag(get_version):
|
async def test_gitlab_max_tag(get_version):
|
||||||
assert await get_version("example", {
|
assert await get_version("example", {
|
||||||
"source": "gitlab",
|
"source": "gitlab",
|
||||||
|
|
Loading…
Add table
Reference in a new issue