问题
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