How to use GitHub V3 API to get commit count for a repo?

前端 未结 7 1952
小鲜肉
小鲜肉 2020-12-05 03:26

I am trying to count commits for many large github repos using the API, so I would like to avoid getting the entire list of commits (this way as an example:

7条回答
  •  执念已碎
    2020-12-05 03:31

    If you're looking for the total number of commits in the default branch, you might consider a different approach.

    Use the Repo Contributors API to fetch a list of all contributors:

    https://developer.github.com/v3/repos/#list-contributors

    Each item in the list will contain a contributions field which tells you how many commits the user authored in the default branch. Sum those fields across all contributors and you should get the total number of commits in the default branch.

    The list of contributors if often much shorter than the list of commits, so it should take fewer requests to compute the total number of commits in the default branch.

提交回复
热议问题