Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GitHub: use_commit_name option #213

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

bb010g
Copy link
Contributor

@bb010g bb010g commented Feb 23, 2022

I would like to use nvchecker to pin check for new Git commits on github without using the git source; this solves that problem. The VER+HASH syntax is compatible with Semantic Versioning, for whatever that's worth.

Also, wider use of the GraphQL API when possible; it's a bit faster than the REST API and I had to use it more for comprehensive use_commit_name support.

nvchecker.util.AsyncCache.get_json() now knows how to send POST requests when a json body parameter is provided; this makes using the GraphQL API more in nvchecker_sources.github easier and more aligned with REST API.

I'm not in love with the list_count option, but I didn't want to break backwards compatibility and I didn't want to be stuck fetching up to approximately 99 commits I don't need if I use use_max_tag in the future. A good way to handle this might be issuing a deprecation notice when list_count isn't specified along with use_max_tag in the future, and then removing the list_count = 100 default so it can be 1 like everywhere else. Talking about other uses of list_count, there is flexibility to make use_latest_tag support list options; I did not expose this functionality in this patch set and it still returns a scalar str for now.

See the individual commit diffs for a smoother progression that doesn't change basically all of nvchecker_sources.github at once.

Based off #212 because I made sure each commit in this set passed tests.

a ` : ` (space, colon, space) like that can be confused for a definition
list classifier, especially in a definition list, so prefer to
backslash-escape the colon.

see the "reStructedText Markup Specification",
section "Syntax Details" > "Body Elements" > "Definition Lists".
the `asyncio_mode` of `legacy` (current default) is deprecated.
`asyncio_mode` will be `strict` by default in the future.
there is currently not GraphQL API equivalent to the REST API's
`/repos/{owner}/{repo}/commits/{ref}` endpoint.
elif isinstance(x, dict):
return tuple(sorted((_normalize(k), _normalize(v)) for k, v in x.items()))
else:
return x
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not obvious what this function does. It needs a docstring or a better name.

_, url, headers = key
res = await session.get(url, headers=dict(headers))
_, url, headers, json = key
json = extra # denormalizing json would be a pain, so we sneak it through
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about passing json as a str or bytes? We can set the Content-Type header and directly pass it to session as body

@@ -393,6 +393,12 @@ use_latest_tag

This requires a token because it's using the v4 GraphQL API.

use_commit_name
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What about use_commit_hash? It's not obvious what a commit name is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants