GitHub REST API:git 标签 --contains

Gui*_*gno 5 github github-api

我正在尝试识别包含特定提交的所有标签。使用 git 命令工具,可以通过以下方式完成此操作:

git tag --contains <commit>
Run Code Online (Sandbox Code Playgroud)

但是,我需要对多个存储库执行此操作,因此我希望依赖 REST API。有没有办法通过 GitHub 的 REST API 收集相同的信息?

Cha*_*had 3

我在一个相关问题上找到了这个答案,为我提供了我需要的东西。

您首先会获得存储库的标签列表:

https://api.github.com/repos/:user/:repo/tags
Run Code Online (Sandbox Code Playgroud)

然后,对于每个标签,您将分支与 SHA 进行比较

https://api.github.com/repos/:user/:repo/compare/:tagName...:sha_of_commit
Run Code Online (Sandbox Code Playgroud)

status如果响应中属性的值为divergedahead,则提交不包含在标记中。status如果属性的值为behindidentical,则提交包含在标记中。