如何通过GitHub API在Git标签中获取所有提交 [英] How to get all commits in a Git tag through GitHub API

查看:334
本文介绍了如何通过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-tags
  • https://developer.github.com/v3/repos/commits/#compare-two-commits

这篇关于如何通过GitHub API在Git标签中获取所有提交的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆