Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get all of a user's public github commits

Regardless of project, I'd like to know if there's an easy way of getting all commits to all public repositories for a single username.

Since I belong to multiple organizations, I'm trying to compile a list of the projects on which I'm a contributor, as well as projects that I have accepted pull requests.

So far my google-fu and looking through the github api docs has proved insufficient.

like image 821
markrickert Avatar asked May 14 '12 21:05

markrickert


People also ask

Can public see commits on GitHub?

As long as people have access to the git repo, anyone can see any commit and any changes on there.


2 Answers

http://zmoazeni.github.com/gitspective/ is your friend. :-) Filter out all but "Push", and you have your view, albeit without the coding work to implement it yourself first.

Inspecting what goes on with the Chrome Devtools "Network" tab might help you mimic the API queries, if you want to redo the work yourself.

like image 150
ecmanaut Avatar answered Sep 21 '22 08:09

ecmanaut


The correct way to do this is via the Events API.

First you need to fetch the user's events:

GET /users/:username/events 

Then you will want to filter the response array for items where type is set to PushEvent. Each one of these items corresponds to a git push by the user. The commits from that push are available in reverse chronological order in the payload.commits array.

The next step is to filter out commits made by other users by checking the author.email property of each commit object. You also have access to properties like sha, message and url on the same object, and you can eliminate duplicate commits across multiple pushes by using the distinct property.

EDIT: As pointed out by Adam Taylor in the comments, this approach is wrong. I failed to RTFM, sorry. The API lets you fetch at most 300 events and events are also limited to the last 90 days. I'll leave the answer here for completeness but for the stated question of fetching all commits, it won't work.

like image 30
Phil Booth Avatar answered Sep 20 '22 08:09

Phil Booth