GitHub api now returns ALL the visible repositories for user

Change the code to simply filter the single list returned, rather than reloading the org repos again
This commit is contained in:
Joseph Schorr 2015-07-22 13:50:46 -04:00
parent 5d86fa80e7
commit 69ca34161c

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], for repository in repos:
namespace = repository.owner.login
if not namespace in namespaces:
namespaces[namespace] = {
'personal': namespace == usr.login,
'repos': [],
'info': { 'info': {
'name': usr.login, 'name': namespace,
'avatar_url': usr.avatar_url, 'avatar_url': repository.owner.avatar_url
} }
} }
repos_by_org = [personal] namespaces[namespace]['repos'].append(repository.full_name)
for org in usr.get_orgs(): entries = list(namespaces.values())
repo_list = [] entries.sort(key=lambda e: e['info']['name'])
for repo in org.get_repos(type='member'): return entries
repo_list.append(repo.full_name)
repos_by_org.append({
'personal': False,
'repos': repo_list,
'info': {
'name': org.name or org.login,
'avatar_url': org.avatar_url
}
})
return repos_by_org
def list_build_subdirs(self): def list_build_subdirs(self):
config = self.config config = self.config