Merge pull request #260 from coreos-inc/githubfix

GitHub api now returns ALL the visible repositories for user
This commit is contained in:
Jimmy Zelinskie 2015-07-22 13:53:58 -04:00
commit 2c29dc048d

View file

@ -704,32 +704,25 @@ class GithubBuildTrigger(BuildTriggerHandler):
except GithubException: except GithubException:
raise RepositoryReadException('Unable to list user repositories') raise RepositoryReadException('Unable to list user repositories')
personal = { namespaces = {}
'personal': True,
'repos': [repo.full_name for repo in repos],
'info': {
'name': usr.login,
'avatar_url': usr.avatar_url,
}
}
repos_by_org = [personal] for repository in repos:
namespace = repository.owner.login
for org in usr.get_orgs(): if not namespace in namespaces:
repo_list = [] namespaces[namespace] = {
for repo in org.get_repos(type='member'): 'personal': namespace == usr.login,
repo_list.append(repo.full_name) 'repos': [],
'info': {
repos_by_org.append({ 'name': namespace,
'personal': False, 'avatar_url': repository.owner.avatar_url
'repos': repo_list, }
'info': {
'name': org.name or org.login,
'avatar_url': org.avatar_url
} }
})
return repos_by_org namespaces[namespace]['repos'].append(repository.full_name)
entries = list(namespaces.values())
entries.sort(key=lambda e: e['info']['name'])
return entries
def list_build_subdirs(self): def list_build_subdirs(self):
config = self.config config = self.config