I am experimenting with GitHub API using octokit ruby gem. My goal is to be able to extract the 'tag' that a commit SHA belongs to.
Now I can easily do this on command line using
> git describe 688ae0b --tags
and get output
> 3.0.1-122-g688ae0b
which tells me Tag, commits since tags, and last commit hash.
How do I get same info from GitHub API?
Answers using GitHub API or Octokit client would both do, as I can translate from one other just fine.
I have looked at a bunch of things like, releases, tags, commits etc.. but none of them give me this information that I can get in one line from command line.
I am not looking for 'how to use github api'. I am looking for specific request or set of requests that will let me derive this information.
Since there is no easy way to run a query like git describe with the GitHub API, that leaves you with an iterative process involving:
trying to diff a tag against your specific commit, with the compare 2 commits API
GET /repos/:owner/:repo/compare/:base...:head
(with base being the commit, and head being the tag)
If there are any result, the commit is accessible from the tag.
(I use a similar approach in "Github API: Finding untagged commits")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With