我想知道如何使用github-api获取项目的所有当前版本或标签.我在github-api中看到了标签的文档,但我没有看到列出所有标签或列出所有版本的方法,但只列出了一个特定的标签:sha.
use*_*702 22
这是可能的,但文档可能不在您期望的位置.
http://developer.github.com/v3/git/refs/
您还可以请求子命名空间.例如,要获取所有标记引用,可以调用:
GET /repos/:owner/:repo/git/refs/tags
Run Code Online (Sandbox Code Playgroud)
今天早上我收到了我发给github支持团队的同一个问题的答案.不确定我如何正确归纳答案,但这是他们的回答.
引自Github支持团队的IvanŽužak
您可以使用此API调用获取存储库的所有标记列表:
http://developer.github.com/v3/repos/#list-tags
因此,例如,发出以下cURL请求将返回libgit2/libgit2存储库的标记列表:
$ curl -v" https://api.github.com/repos/libgit2/libgit2/tags "
注意:对于GitHub 存储库的特定版本,您现在拥有(自 2013 年 9 月 25 日起),一个用于列出所有版本的api:
具有拉取访问权限的用户将仅收到已发布的版本。
GET /repos/:owner/:repo/releases
Run Code Online (Sandbox Code Playgroud)回复
Status: 200 OK
X-RateLimit-Limit: 5000
X-RateLimit-Remaining: 4999
[
{
"url": "https://api.github.com/repos/octocat/Hello-World/releases/1",
"html_url": "https://github.com/octocat/Hello-World/releases/v1.0.0",
"assets_url": "https://api.github.com/repos/octocat/Hello-World/releases/1/assets",
"upload_url": "https://uploads.github.com/repos/octocat/Hello-World/releases/1/assets{?name}",
"id": 1,
"tag_name": "v1.0.0",
"target_commitish": "master",
"name": "v1.0.0",
"body": "Description of the release",
"draft": false,
"prerelease": false,
"created_at": "2013-02-27T19:35:32Z",
"published_at": "2013-02-27T19:35:32Z"
}
]
Run Code Online (Sandbox Code Playgroud)
GET /repos/:owner/:repo/releases/:id
Run Code Online (Sandbox Code Playgroud)
在 v4、graphQL 中,您可以使用此查询https://developer.github.com/v4/object/tag/
query {
repository(owner: "onmyway133", name: "Scale") {
refs(refPrefix: "refs/tags/", last: 2) {
edges {
node {
name
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)