GitHub API:提交所属的标签(git describe --tag< sha>并行) [英] GitHub API: Tag a commit belongs to ( parallel for git describe --tag <sha> )
问题描述
我正在使用 octokit ruby gem来尝试GitHub API.我的目标是能够提取提交SHA所属的标签".
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.
现在,我可以使用
> git describe 688ae0b --tags
并获取输出
> 3.0.1-122-g688ae0b
告诉我Tag,从标签开始提交,最后一次提交哈希.
which tells me Tag, commits since tags, and last commit hash.
如何从GitHub API获取相同的信息?
使用GitHub API或Octokit客户端的答案都可以,因为我可以互相翻译.
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.
我不是在寻找如何使用github api".我正在寻找特定的请求或一组请求,这些信息可以让我得出此信息.
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.
推荐答案
由于没有简单的方法可以通过GitHub API运行诸如git describe之类的查询,因此需要进行以下迭代过程:
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:
- 列出所有标签
(以base为提交,head为标签)
(with base being the commit, and head being the tag)
如果有任何结果,则可以从标记访问提交.
If there are any result, the commit is accessible from the tag.
(我在" Github API:查找未标记的提交中使用了类似的方法")
这篇关于GitHub API:提交所属的标签(git describe --tag< sha>并行)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!