如何找到用户贡献的github中的所有公共存储库?

时间:2013-09-10 05:10:08

标签: python github3.py

我正在使用github3 python library并且正在尝试查找我们组织中的用户所做出贡献的所有公共回购(以奖励开源的支持!)。
我已经获得了该组织的用户列表,但现在是什么? 我可以使用公共事件迭代器来查找repos吗?

#!/usr/bin/env python
import argparse
import github3


def get_organization(github, name):
    for organization in github.iter_orgs():
        if organization.login == name:
            return organization


def main(args):
    github = github3.login(args.github_username, password=args.github_password)
    organization = get_organization(github, args.organization)

    # Get a list of all current organization contributors
    orgMembers = [member.login for member in organization.iter_members()]

# now what?  

1 个答案:

答案 0 :(得分:2)

您可以举例of test_github.py

def test_iter_user_repos(self):
    self.response('repo', _iter=True)
    self.get('https://api.github.com/users/sigmavirus24/repos')
    self.conf.update(params={'type': 'all', 'direction': 'desc'})

    next(self.g.iter_user_repos('sigmavirus24', 'all', direction='desc'))
    self.mock_assertions()

    self.conf.update(params={"sort": "created"})
    self.get('https://api.github.com/users/sigmavirus24/repos')

    assert isinstance(next(self.g.iter_user_repos('sigmavirus24', sort="created")),
                      github3.repos.Repository)
    self.mock_assertions()

它基于“GitHub API”中提到的How to retrieve the list of all github repositories of a person?

/users/:user/repos

(仅限公共回购)