githubgithub-api

github api: How to efficiently find the number of commits for a repository?


I want to find the number of commits done to specific github projects, and within them to specific files. I checked the github api docs but only found an API for actually returning all commits. This would be very inefficient since I have to do multiple api calls for paging thru all commits.

Anyone has a better idea?


Solution

  • Update May 2013: see "File CRUD and repository statistics now available in the API"

    You now can Get the last year of commit activity data

    GET /repos/:owner/:repo/stats/commit_activity
    

    Returns the last year of commit activity grouped by week. The days array is a group of commits per day, starting on Sunday.

    Not completely what you are looking for, but closer.


    Original answer (April 2010)

    No, the current API doesn't support a 'log --all' for listing all commmits from all branches.

    The only alternative is presented in "Github API: Retrieve all commits for all branches for a repo", and list through all pages of all commits, branch after branch.

    This seems so cumbersome than another alternative would actually to clone the Github repo and apply git commands on that local clone!
    (mainly git shortlog)


    Note: you can also checkout that python script created by Arcsector.