0

I am looking for a way to count the number of PDF files in all repositories existing in a self hosted github server (Github Enterprise). I've got the idea of iterating over all the repositories, list the existing files and count but I'm not sure if this is the best idea. What would be the recommended way to do that ?

Thanks

OmarZ
  • 33
  • 5

1 Answers1

0

You could use Github API code search using :

https://api.github.com/search/code?q=extension:pdf%20repo:google/language-resources

or for enterprise :

http(s)://[hostname]/api/v3/search/code?q=extension:pdf%20repo:org/repo-name

A repository or organization must be specified when using the query, so you could make one request per repository :

  • get the full list of repository
  • for each one, execute http(s)://[hostname]/api/v3/search/code?q=extension:pdf%20repo:org/repo-name
Bertrand Martel
  • 42,756
  • 16
  • 135
  • 159
  • Thanks for the suggestion. I believe this solution would be very time consuming as it requires iterating over all the repositories of a self hosted Github Enterprise and it is considered as my last shot. I even checked GitHub GraphQL API v4 but I didn't found any positive results. – OmarZ Sep 25 '20 at 15:36