Is There A Way To Get Tag Objects Instead Of Reference Ones When Listing Tags From A Repository?
I'm able to successfully list tags from a repository using github3 using: repo.iter_refs(subspace='tags') That results in a generator of github3.git.Reference objects. Is there a
Solution 1:
So the only way to get a github3.git.Tag
object back is if you're trying to retrieve a specific annotated tag (which is a tag created in a very specific manner).
If this is what you're trying to do then your code would look something like
tags = [repo.tag(r.object.sha) for r in repo.iter_refs(subspace='refs')]
You can get a lightweight tag (which is what most tags on GitHub actually are) by either your current method or by doing repo.iter_tags()
. Either will work. The latter will return github3.repos.RepoTag
, not a github3.git.Tag
though because the API returns much different information for each.
Post a Comment for "Is There A Way To Get Tag Objects Instead Of Reference Ones When Listing Tags From A Repository?"