How to get all commits in a Git tag through GitHub API

强颜欢笑 提交于 2020-05-27 04:11:44

问题


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.

For example the Git UI says Tagging Tag1 and has a sha associated with it... let's say the sha is : SHA1

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.


回答1:


Based on the clarification on your comment:

I want to get all commits between this newly created tag and previous tag

1. Get all the tags in a given repo, so you can get the current and the previous tag names

curl -X "GET" "https://api.github.com/repos/:owner/:repo/tags" \
     -H "Authorization: token YOUR_GITHUB_ACCESS_TOKEN"

2. Get all the commits between the latest 2 tags

curl -X "GET" "https://api.github.com/repos/:owner/:repo/compare/:tag_1...:tag_2" \
     -H "Authorization: token YOUR_GITHUB_ACCESS_TOKEN"

Doc links:

  • https://developer.github.com/v3/repos/#list-tags
  • https://developer.github.com/v3/repos/commits/#compare-two-commits


来源:https://stackoverflow.com/questions/40293833/how-to-get-all-commits-in-a-git-tag-through-github-api

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!