如何获得我在去年贡献的所有 GitHub 项目的列表? [英] How do I get a list of all the GitHub projects I've contributed to in the last year?

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

问题描述

我意识到我可以点击 https://api.github.com/users/:user_id/repos 来获取我拥有或已经分叉的所有存储库的列表.但我想做的是找出我在过去一年中贡献的所有项目(提交、拉取请求、问题等).事件 API 让我获得最后 300事件,但在过去的 12 个月里,我贡献了 很多.这可能吗?

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 脚本我的贡献:

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;

是的,HTML 抓取有点难看,但它满足了我的需要.

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

这篇关于如何获得我在去年贡献的所有 GitHub 项目的列表?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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