如何通过GitHub API在Git标签中获取所有提交
我必须获取所有新提交,这些新提交是在Git存储库上创建新标签时的一部分.这需要通过GitHub API完成.
I have to fetch all new commits that were a part when a new tag was created on a Git repo. This needs to be done through GitHub API.
例如,Git用户界面显示Tagging Tag1并与之关联的sha ...假设sha为:SHA1
For example the Git UI says Tagging Tag1 and has a sha associated with it... let's say the sha is : SHA1
现在如何通过GitHub API获取所有已发生或属于Tag1的提交?我想存储所有这些提交并对其进行一些分析.
Now how do I get all commits which happened or were a part of Tag1 through GitHub API? I want to store all these commits and perform some analysis on them.
基于您的评论的澄清:
我想获得这个新创建的标签和上一个标签之间的所有提交
I want to get all commits between this newly created tag and previous tag
1.获取给定存储库中的所有标签,以便获得当前和以前的标签名称
curl -X "GET" "https://api.github.com/repos/:owner/:repo/tags" \
-H "Authorization: token YOUR_GITHUB_ACCESS_TOKEN"
2.获取最近2个标记之间的所有提交
curl -X "GET" "https://api.github.com/repos/:owner/:repo/compare/:tag_1...:tag_2" \
-H "Authorization: token YOUR_GITHUB_ACCESS_TOKEN"
文档链接:
- https://developer.github.com/v3/repos/#list-标签
- https://developer.github.com/v3/repos /commits/#compare-two-commits
- https://developer.github.com/v3/repos/#list-tags
- https://developer.github.com/v3/repos/commits/#compare-two-commits