mirror of
https://github.com/lilydjwg/nvchecker.git
synced 2025-03-10 06:14:02 +00:00
github: full use_commit_name
support
This commit is contained in:
parent
cdd31a01e4
commit
03a83d8278
3 changed files with 52 additions and 7 deletions
|
@ -397,6 +397,8 @@ use_commit_name
|
||||||
Set this to ``true`` to append a plus and the commit name to the version, e.g.
|
Set this to ``true`` to append a plus and the commit name to the version, e.g.
|
||||||
``20130701.012212+e1457aadd30f53f4d50d6c4828d517355c09b8ae``.
|
``20130701.012212+e1457aadd30f53f4d50d6c4828d517355c09b8ae``.
|
||||||
|
|
||||||
|
If this isn't showing up, provide a token so it can use the v4 GraphQL API.
|
||||||
|
|
||||||
query
|
query
|
||||||
When ``use_latest_tag`` is ``true``, this sets a query for the tag. The exact
|
When ``use_latest_tag`` is ``true``, this sets a query for the tag. The exact
|
||||||
matching method is not documented by GitHub.
|
matching method is not documented by GitHub.
|
||||||
|
|
|
@ -98,6 +98,20 @@ query latestTag(
|
||||||
}
|
}
|
||||||
'''
|
'''
|
||||||
|
|
||||||
|
QUERY_LATEST_RELEASE = '''
|
||||||
|
query latestRelease(
|
||||||
|
$owner: String!, $name: String!,
|
||||||
|
$includeCommitName: Boolean = false,
|
||||||
|
) {
|
||||||
|
repository(owner: $owner, name: $name) {
|
||||||
|
latestRelease {
|
||||||
|
tagName
|
||||||
|
... @include(if: $includeCommitName) { tagCommit { oid } }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
'''
|
||||||
|
|
||||||
async def get_version_real(
|
async def get_version_real(
|
||||||
name: str, conf: Entry, *,
|
name: str, conf: Entry, *,
|
||||||
cache: AsyncCache, keymanager: KeyManager,
|
cache: AsyncCache, keymanager: KeyManager,
|
||||||
|
@ -137,14 +151,35 @@ async def get_version_real(
|
||||||
)
|
)
|
||||||
return ref
|
return ref
|
||||||
elif conf.get('use_latest_release', False):
|
elif conf.get('use_latest_release', False):
|
||||||
data = await query_rest(
|
tag = None
|
||||||
cache = cache,
|
if token:
|
||||||
token = token,
|
owner, reponame = repo.split('/')
|
||||||
url = GITHUB_LATEST_RELEASE % repo,
|
j = await query_graphql(
|
||||||
)
|
cache = cache,
|
||||||
if 'tag_name' not in data:
|
token = token,
|
||||||
|
query = QUERY_LATEST_RELEASE,
|
||||||
|
variables = {
|
||||||
|
'owner': owner,
|
||||||
|
'name': reponame,
|
||||||
|
'includeCommitName': use_commit_name,
|
||||||
|
},
|
||||||
|
)
|
||||||
|
release = j['data']['repository']['latestRelease']
|
||||||
|
if release is not None:
|
||||||
|
tag = add_commit_name(
|
||||||
|
release['tagName'],
|
||||||
|
release['tagCommit']['oid'] if use_commit_name else None,
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
data = await query_rest(
|
||||||
|
cache = cache,
|
||||||
|
token = token,
|
||||||
|
url = GITHUB_LATEST_RELEASE % repo,
|
||||||
|
)
|
||||||
|
if 'tag_name' in data:
|
||||||
|
tag = data['tag_name']
|
||||||
|
if tag is None:
|
||||||
raise GetVersionError('No release found in upstream repository.')
|
raise GetVersionError('No release found in upstream repository.')
|
||||||
tag = data['tag_name']
|
|
||||||
return tag
|
return tag
|
||||||
elif conf.get('use_max_tag', False):
|
elif conf.get('use_max_tag', False):
|
||||||
data = await query_rest(
|
data = await query_rest(
|
||||||
|
|
|
@ -35,6 +35,14 @@ async def test_github_latest_release(get_version):
|
||||||
"use_latest_release": True,
|
"use_latest_release": True,
|
||||||
}) == "release3"
|
}) == "release3"
|
||||||
|
|
||||||
|
async def test_github_latest_release_commit_name(get_version):
|
||||||
|
assert await get_version("example", {
|
||||||
|
"source": "github",
|
||||||
|
"github": "harry-sanabria/ReleaseTestRepo",
|
||||||
|
"use_latest_release": True,
|
||||||
|
"use_commit_name": True,
|
||||||
|
}) == "release3+2b3cdf6134b07ae6ac77f11b586dc1ae6d1521db"
|
||||||
|
|
||||||
async def test_github_max_tag(get_version):
|
async def test_github_max_tag(get_version):
|
||||||
assert await get_version("example", {
|
assert await get_version("example", {
|
||||||
"source": "github",
|
"source": "github",
|
||||||
|
|
Loading…
Add table
Reference in a new issue