我如何获得过去一年贡献的所有GitHub项目的清单? [英] How do I get a list of all the GitHub projects I've contributed to in the last year?
问题描述
我知道我可以点击 https://api.github.com/users/:user_id/repos
来获取我拥有或已经分配的所有repos的列表。但是,我想做的是弄清楚在过去一年中我所做的所有项目(提交,提出请求,问题等)。 events API 可让我获得最后300个事件,但我已经贡献了一个批次比在过去的十二个月。这是可能的吗?
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?
推荐答案
感谢 @caged 的推文,我写了这个Perl脚本在我的贡献:
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;
是的,HTML抓取是一种丑陋,但是为了我的需要做了一切。
Yeah, HTML scraping is kind of ugly, but did the trick for my needs.
这篇关于我如何获得过去一年贡献的所有GitHub项目的清单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!