githubgithub-api

GitHub API (v3): Order tags by creation date


I ran into a problem / question while using the GitHub API.

I need a list of all tags created after a single tag. The only way to do this, is to compare the tags by date. However, the results from the API aren't ordered by date:

Result from the API (rails repository example):

API results

Results from the webinterface:

Webinterface results

What i did expect is a list ordered by date. However, as you can see in the pictures: the API is returning v4.0.0rc1 & v4.0.0rc2 before the release of v4.0.0, while 4.0.0 is released after the release candidates. There isn't even a creation / commit date to order at server side.

The releases API isn't a solution either. This API is only returning releases created by Github, not the releases created by tags.

Is there any way to order the tags by date?


Solution

  • The Repositories API currently returns tags in the order they would be returned by the "git tag" command, which means they are alphabetically sorted.

    The problem with sorting tags chronologically in Git is that there are two types of tags, lightweight and annotated), and for the lightweight type Git doesn't store the creation date.

    The Releases/Tags UI currently sorts tags chronologically by the date of the commit to which the tag points to. This again isn't the date on which the tag itself was created, but it does establish a chronological order of things.

    Adding this alternative sorting option to the API is on our feature request list.


    Here is sample code for those who need to get github tag created_at time