Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get a list of all the GitHub projects I've contributed to in the last year? [duplicate]

Tags:

github

events

api

I realize I can hit https://api.github.com/users/:user_id/repos to get a list of all the repos I own or have forked. But what I would like to do is figure out all of the projects I have contributed to (commits, pull requests, issues, etc.) over the last year. The events API lets me get the last 300 events, but I have contributed a lot more than that in the last twelve months. Is this possible?

like image 865
theory Avatar asked Jan 24 '14 01:01

theory


People also ask

How do I find my GitHub repository history?

On GitHub, you can see the commit history of a repository by: Navigating directly to the commits page of a repository. Clicking on a file, then clicking History, to get to the commit history for a specific file.

Why does GitHub not show my contributions?

Your local Git commit email isn't connected to your account Commits must be made with an email address that is connected to your account on GitHub.com, or the GitHub-provided noreply email address provided to you in your email settings, in order to appear on your contributions graph.


1 Answers

Thanks to a tweet from @caged, I wrote this Perl script to iterate over months in my contributions:

use v5.12; use warnings; use utf8; my $uname = 'theory';  my %projects; for my $year (2012..2014) {     for my $month (1..12) {         last if $year == 2014 && $month > 1;         my $from = sprintf '%4d-%02d-01', $year, $month;         my $to   = sprintf '%4d-%02d-01', $month == 12 ? ($year + 1, 1) : ($year, $month + 1);         my $res = `curl 'https://github.com/$uname?tab=contributions&from=$from&to=$to' | grep 'class="title"'`;         while ($res =~ /href="([^"?]+)/g) {             my (undef, $user, $repo) = split m{/} => $1;             $projects{"$user/$repo"}++;         }     } }  say "$projects{$_}: $_" for sort keys %projects; 

Yeah, HTML scraping is kind of ugly, but did the trick for my needs.

like image 148
theory Avatar answered Sep 29 '22 11:09

theory