我如何得到所有GitHub的项目,我在去年做出了贡献的名单? [英] How do I get a list of all the GitHub projects I've contributed to in the last year?

查看:316
本文介绍了我如何得到所有GitHub的项目,我在去年做出了贡献的名单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以按 https://api.github.com/users/:user_id/repos 来得到所有我拥有或已付出了回购的清单。但我想这样做是弄清楚我不得不做出贡献的项目(提交,拉请求,问题等)在过去的一年。该事件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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆