Reputation: 557
I'm trying to identify all the tags that contains a specific commit. Using git command tools, this can be done through:
git tag --contains <commit>
However, I need to do this for several repositories so I was expecting on relying on the REST API. Is there a way to gather the same information through GitHub's REST API?
Upvotes: 5
Views: 1949
Reputation: 2456
I found this answer on a related question to give me what I needed.
You would first get a list of tags for your repo:
https://api.github.com/repos/:user/:repo/tags
Then, for each tag, you would compare the branch with the SHA:
https://api.github.com/repos/:user/:repo/compare/:tagName...:sha_of_commit
If the value of the status
attribute in the response is diverged
or ahead
, then the commit is not contained in the tag. If the value of the status
attribute is behind
or identical
, then the commit is contained in the tag.
Upvotes: 3