Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I find all public repos in github that a user contributes to?

I'm using the github3 python library and am trying to find all public repos that users from our organization have contributed to (to reward the support of open source!).
I've got the list of users for the organization, but now what?
Can I use the public events iterator to find 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?  
like image 278
user2763603 Avatar asked Sep 10 '13 05:09

user2763603


People also ask

How do I see contributors in GitHub repository?

On GitHub.com, navigate to the main page of the repository. Under your repository name, click Insights. In the left sidebar, click Contributors. Optionally, to view contributors during a specific time period, click, then drag until the time period is selected.

How do I list all repositories on GitHub?

How To List All Public Repositories Belonging to a User? So, to list all public repos from a user, send a GET request to https://api.github.com/users/<USER-NAME>/repos , replacing with the actual user from whom you want to retrieve the repositories.

How do I find someone's GitHub repository?

Go here: https://github.com/search and enter "pattern repo:user_name/repo_name". because by default it searches for repositories matching that search string... So just click on the left on "Code" and it will display what you want.

How can I see what repositories are shared with me?

You can see the repositories where you're a collaborator. To do this, head to the Repositories section of your account's settings (https://github.com/settings/repositories). There should be a Leave action button aside each repository you're a collaborator on.


1 Answers

You can take an example 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()

It is based on the GitHub API mentioned in "How to retrieve the list of all github repositories of a person?":

/users/:user/repos

(public repos only)

like image 68
VonC Avatar answered Oct 17 '22 04:10

VonC