-1

Currently now github allows me to find the commits of a repo but in an organization there are many repos using this below

https://api.github.com/repos/OWNER/REPO/commits

I want to find the total of all the repos without looping through and summing all of them. Is there a faster way to get the total commits of an organization

i tried https://api.github.com/repos/OWNER/REPO/commits this for every repo but the time taken to run is very long so i wanted to find a better alternative.

3
  • Have you looked through the Github API docs? If you cannot find a means, then it probably doesn't exist Commented Jun 25, 2024 at 4:36
  • Start the process now, it might finish before you get a better solution. Commented Jun 25, 2024 at 5:04
  • yeah have looked at the docs but doesn't seem to find one.. the process is taking me like 7 hrs for just 10 rows of data(10 organisations total commit) .. Commented Jun 25, 2024 at 5:17

1 Answer 1

0

A faster option might be to use the Github API to list all public repositories of an organization. For each repository only clone the commits using git clone --filter=object:type=commit. Then use git to examine the commits.

Here's some pseudo code to explain how to count every commit in an organization.

num_commits = 0
for repo in org.repos
  git clone --filter=object:type=commit repo.url
  cd into repo
  num_commits += git rev-list --all --count

This has the potential to be very efficient because the commit objects are very small and cloning is very efficient. Much more efficient than paging through every commit with a JSON API.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.