Quantcast
Viewing latest article 5
Browse Latest Browse All 7

Answer by Mihai Parparita for Finding the oldest commit in a GitHub repository via the API

This can be done in as few as two requests, if data is already cached (on GitHub's side) and depending on your precision requirements.

First check to see if there are in fact commits before the creation time by doing a GET for /repos/:owner/:repo/commits with the until parameter set to the creation time (as suggested by VonC's answer) and limiting the number returned to 1 commit (via the per_page parameter).

If there are commits before the creation time, then the contributors statistics endpoint (/repos/:owner/:repo/stats/contributors) can be invoked. The response has a weeks list per contributor, and the oldest w value there is the same week as the oldest commit.

If you need a precise timestamp, you can then use the commits listing endpoint again with until and since set to the 7 days after the oldest week value.

Note that the statistics endpoint may return a 202 indicating that statistics are not available, in which case a retry in a few seconds is required.


Viewing latest article 5
Browse Latest Browse All 7

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>