Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all commits in a Git tag through 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.

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.

like image 387
AS_ON Avatar asked Oct 27 '16 20:10

AS_ON


1 Answers

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"

tags

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"

enter image description here

Doc links:

  • https://developer.github.com/v3/repos/#list-tags
  • https://developer.github.com/v3/repos/commits/#compare-two-commits
like image 63
rebagliatte Avatar answered Sep 18 '22 18:09

rebagliatte