如何通过github API获取所有用户存储库? (包括固定存储库) [英] How to get all user repositories by github api? (including Pinned repositories)

查看:241
本文介绍了如何通过github API获取所有用户存储库? (包括固定存储库)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用 PyGithub 获取所有用户的存储库. 为了清楚起见,用户: https://github.com/mbostock 具有53个公共存储库.

I' trying get all user's repositories by using PyGithub. For clarity the user: https://github.com/mbostock has 53 public repos.

我的代码:

import github
con = github.Github(mylogin, pass)
u = g.get_user('mbostock').get_repos('all')

我得到53,这是正确的数字,但是,我注意到在所有收到的存储库中我找不到某些用户的固定存储库,例如 d3/d3 ,尽管该用户也为此回购做出了很大贡献.

and I get 53, It's correct number but, I have noticed that among all received repos I can't find some user's Pinned repositories, for example d3/d3, although that user also make big contribution on this repo.

如果有人知道github api,以及接收所有用户贡献的存储库的方式,请帮忙.

If somebody know github api, and way of receiving all user's contributed repos, please help.

推荐答案

并非所有用户固定的存储库都属于该用户-它们属于该用户恰好是其成员的组织,因此它们不会显示通过GET /users/:user/repos用户的存储库询问API时(抱歉,我对PyGithub并不熟悉,所以我只讲标准的API URL).

Not all of the user's pinned repositories belong to that user—they belong to organisations that the user happens to be a member of, so they won't show up when asking the API for the user's repositories via GET /users/:user/repos (apologies, I'm not familiar with PyGithub so I'll speak only in the standard API URLs).

没有简单的方法就可以获取用户贡献的存储库列表,而无需进行多个API查询-例如,获取用户所属组织的列表(GET /user/:user/orgs),然后列出该组织中的存储库(GET /orgs/:org/repos).但是,使用这种方法并不能保证用户为组织中的每个存储库做出了贡献.

There's no easy way to get a list of repositories that a user contributes to without making multiple API queries—for example to get a list of organisations the user belongs to (GET /user/:user/orgs), and then listing the repositories in that organisation (GET /orgs/:org/repos). However, using this approach there's no guarantee the user contributed to each repository in the organisation.

您当然可以按提交作者进行进一步过滤,但是到那时,您可能已经花费了很多精力(和速率限制).

You could of course further filter by commit authors, but at this point you will probably have expended a lot of effort (and rate limit).

这篇关于如何通过github API获取所有用户存储库? (包括固定存储库)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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