2015-11-19 96 views
9

我想要使用此github api得到回购的所有贡献者。如何检索使用github api回购的所有贡献者

如果我没有错,它也告诉我,如果有超过500个回购人的贡献者,它只会给他们500个,其余的被标记为匿名。

出于性能原因,只有存储库中的前500个作者电子邮件地址将链接到GitHub用户。

这个回购linux kernel有5K +贡献者,根据api我应该通过API获得至少500个贡献者。

当我做curl -I https://api.github.com/repos/torvalds/linux/contributors?per_page=100

我只得到3页(per_page = 100),所以我得到> 300个贡献者。(看“联系”报头)

有没有办法让所有的贡献者回购(5000+)?

HTTP/1.1 200 OK 
Server: GitHub.com 
Date: Thu, 19 Nov 2015 18:00:54 GMT 
Content-Type: application/json; charset=utf-8 
Content-Length: 100308 
Status: 200 OK 
X-RateLimit-Limit: 60 
X-RateLimit-Remaining: 56 
X-RateLimit-Reset: 1447958881 
Cache-Control: public, max-age=60, s-maxage=60 
Last-Modified: Thu, 19 Nov 2015 16:06:38 GMT 
ETag: "a57e0f74fc68e1791da15d33fa044616" 
Vary: Accept 
X-GitHub-Media-Type: github.v3 
Link: <https://api.github.com/repositories/2325298/contributors?per_page=100&page=2>; rel="next", <https://api.github.com/repositories/2325298/contributors?per_page=100&page=3>; rel="last" 
X-XSS-Protection: 1; mode=block 
X-Frame-Options: deny 
Content-Security-Policy: default-src 'none' 
Access-Control-Allow-Credentials: true 
Access-Control-Expose-Headers: ETag, Link, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval 
Access-Control-Allow-Origin: * 
Strict-Transport-Security: max-age=31536000; includeSubdomains; preload 
X-Content-Type-Options: nosniff 
Vary: Accept-Encoding 
X-Served-By: a30e6f9aa7cf5731b87dfb3b9992202d 
X-GitHub-Request-Id: 67E881D2:146C9:24CF1BB3:564E0E55 
+0

http://stackoverflow.com/questions/18148490/how-can-i-get-more-than-100-results-from-github-api-v3-using-github-api-gem –

回答

0

由于GitHub的API似乎并不支持这一点,另一种方法(更慢得多的方法)将克隆回购,然后运行这个命令(获得名称):

git log --all --format='%aN' | sort -u 

要获取电子邮件地址的结果(这应该警惕撰稿人姓名配置的变化,将更加准确):

git log --all --format='%aE' | sort -u 

如果您需要此功能,任何回购你可以写一个简单的脚本ŧ hat会采取存储库路径,克隆回购,运行命令,然后删除下载的回购。

与此同时,你可以在contact GitHub希望他们增加优先级扩大/修复他们的API。

+0

这是无限的比使用GitHub API慢。遍历贡献者列表有更好的方法。 – Whitecat

+0

@Whitecat但是Github API并不是所有的信息,那么这就是目前独特的方式。 – deFreitas