我正在尝试识别包含特定提交的所有标签。使用 git 命令工具,可以通过以下方式完成:
git tag --contains <commit>
但是,我需要为多个存储库执行此操作,因此我期望依赖 REST API。有没有办法通过 GitHub 的 REST API 收集相同的信息?
最佳答案
我找到了 this answer在一个相关的问题上给我我需要的东西。
你先get a list of tags对于您的 repo :
https://api.github.com/repos/:user/:repo/tags
然后,对于每个标签,您将 compare the branch with the SHA :
https://api.github.com/repos/:user/:repo/compare/:tagName...:sha_of_commit
如果
status
的值响应中的属性是 diverged
或 ahead
,则提交不包含在标记中。如果status
的值属性是 behind
或 identical
,则提交包含在标记中。
关于GitHub REST API : git tag --contains,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36184945/