Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Count number of empty repositories on GitHub

Tags:

github

I was just wondering if it's possible to count the total number of empty repositories on GitHub.

If not for all users, can it be done for yourself?

Edit

I have tried the size:0 search, but it seems to return a lot of repositories which do contain data. Taking something like size:0..1 didn't help either.

If I try searching for the keyword empty, but it doesn't cover all aspects.

Update

I got a response from Brian Levine (GitHub)

That would be an interesting statistic. We don't have a simple way to do that right now. However, you might be able to use the GitHub API to get close. You could look through public repositories and compare "pushed_at" and "created_at" dates to see if there has been any activity. Additionally, you could find repositories with a "size" of 0. There's more information on how to find this information, and much more, right here:

http://developer.github.com/v3/repos/

like image 268
Aniket Avatar asked Mar 21 '23 17:03

Aniket


2 Answers

You could:

  • list all public repos through the API, and,
  • for each repo, check the ones with a size equals to 0.
    (The size seems to be in KB)

    GET /repos/:owner/:repo
    

Note that an "empty" repo could still have at least one commit, when created with the default README.md description file.
Actually, as the OP Aniket comments:

I explained the meaning of empty as: 0-1 commits, max 3 files:

.gitignore
README.md
LICENSE 

(Note: README is different from README.md)

Another way is, for each repo, to look at the number of commits.
0 or 1 commit means probably an empty repo.


Update: GitHub confirms there is no current way to determine if a repo is "empty".
The closest way to do that would be:

You could look through public repositories and compare "pushed_at" and "created_at" dates to see if there has been any activity

like image 153
VonC Avatar answered Apr 25 '23 07:04

VonC


To check if a repository is empty, look to see if it has any commits.

https://api.github.com/repos/:owner/:repo/commits?per_page=1

An empty repository will have a non-successful HTTP status and the content...

{
  "message": "Git Repository is empty.",
  "documentation_url": "https://developer.github.com/v3"
}

If it doesn't exist, you'll get a 404 and...

{
  "message": "Not Found",
  "documentation_url": "https://developer.github.com/v3"
}

If it does exist, you'll get an HTTP 200 and one commit.

like image 32
Schwern Avatar answered Apr 25 '23 08:04

Schwern