parent
66b3d45fbc
commit
80e2739b41
1 changed files with 22 additions and 1 deletions
|
@ -729,12 +729,14 @@ class GithubBuildTrigger(BuildTriggerHandler):
|
||||||
raise RepositoryReadException('Unable to list user repositories')
|
raise RepositoryReadException('Unable to list user repositories')
|
||||||
|
|
||||||
namespaces = {}
|
namespaces = {}
|
||||||
|
has_non_personal = False
|
||||||
|
|
||||||
for repository in repos:
|
for repository in repos:
|
||||||
namespace = repository.owner.login
|
namespace = repository.owner.login
|
||||||
if not namespace in namespaces:
|
if not namespace in namespaces:
|
||||||
|
is_personal_repo = namespace == usr.login
|
||||||
namespaces[namespace] = {
|
namespaces[namespace] = {
|
||||||
'personal': namespace == usr.login,
|
'personal': is_personal_repo,
|
||||||
'repos': [],
|
'repos': [],
|
||||||
'info': {
|
'info': {
|
||||||
'name': namespace,
|
'name': namespace,
|
||||||
|
@ -742,8 +744,27 @@ class GithubBuildTrigger(BuildTriggerHandler):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if not is_personal_repo:
|
||||||
|
has_non_personal = True
|
||||||
|
|
||||||
namespaces[namespace]['repos'].append(repository.full_name)
|
namespaces[namespace]['repos'].append(repository.full_name)
|
||||||
|
|
||||||
|
# In older versions of GitHub Enterprise, the get_repos call above does not
|
||||||
|
# return any non-personal repositories. In that case, we need to lookup the
|
||||||
|
# repositories manually.
|
||||||
|
# TODO: Remove this once we no longer support GHE versions <= 2.1
|
||||||
|
if not has_non_personal:
|
||||||
|
for org in usr.get_orgs():
|
||||||
|
repo_list = [repo.full_name for repo in org.get_repos(type='member')]
|
||||||
|
namespaces[org.name] = {
|
||||||
|
'personal': False,
|
||||||
|
'repos': repo_list,
|
||||||
|
'info': {
|
||||||
|
'name': org.name or org.login,
|
||||||
|
'avatar_url': org.avatar_url
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
entries = list(namespaces.values())
|
entries = list(namespaces.values())
|
||||||
entries.sort(key=lambda e: e['info']['name'])
|
entries.sort(key=lambda e: e['info']['name'])
|
||||||
return entries
|
return entries
|
||||||
|
|
Reference in a new issue