Fix avatar URLs for non-owner namespaces in Gitlab
This commit is contained in:
parent
9d781b25e5
commit
c8950f34b1
2 changed files with 18 additions and 6 deletions
|
@ -277,11 +277,17 @@ class GitLabBuildTrigger(BuildTriggerHandler):
|
||||||
for repo in repositories:
|
for repo in repositories:
|
||||||
namespace = repo['namespace']
|
namespace = repo['namespace']
|
||||||
namespace_id = namespace['id']
|
namespace_id = namespace['id']
|
||||||
|
|
||||||
|
avatar_url = ''
|
||||||
|
if 'avatar' in namespace:
|
||||||
|
avatar_url = namespace.get('avatar', {}).get('url')
|
||||||
|
elif 'owner' in repo:
|
||||||
|
avatar_url = repo.get('owner', {}).get('avatar_url')
|
||||||
|
|
||||||
if namespace_id in namespaces:
|
if namespace_id in namespaces:
|
||||||
namespaces[namespace_id]['score'] = namespaces[namespace_id]['score'] + 1
|
namespaces[namespace_id]['score'] = namespaces[namespace_id]['score'] + 1
|
||||||
else:
|
else:
|
||||||
owner = repo['namespace']['name']
|
owner = repo['namespace']['name']
|
||||||
avatar_url = repo.get('owner', {}).get('avatar_url')
|
|
||||||
namespaces[namespace_id] = {
|
namespaces[namespace_id] = {
|
||||||
'personal': owner == current_user['username'],
|
'personal': owner == current_user['username'],
|
||||||
'id': namespace['path'],
|
'id': namespace['path'],
|
||||||
|
|
|
@ -26,8 +26,8 @@ def get_currentuser_mock():
|
||||||
'username': 'knownuser'
|
'username': 'knownuser'
|
||||||
}
|
}
|
||||||
|
|
||||||
def project(namespace, name):
|
def project(namespace, name, is_org=False):
|
||||||
return {
|
data = {
|
||||||
'id': '%s/%s' % (namespace, name),
|
'id': '%s/%s' % (namespace, name),
|
||||||
'default_branch': 'master',
|
'default_branch': 'master',
|
||||||
'namespace': {
|
'namespace': {
|
||||||
|
@ -52,11 +52,17 @@ def project(namespace, name):
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if is_org:
|
||||||
|
del data['owner']['avatar_url']
|
||||||
|
data['namespace']['avatar'] = {'url': 'avatarurl'}
|
||||||
|
|
||||||
|
return data
|
||||||
|
|
||||||
def getprojects_mock(page=1, per_page=100):
|
def getprojects_mock(page=1, per_page=100):
|
||||||
return [
|
return [
|
||||||
project('knownuser', 'somerepo'),
|
project('knownuser', 'somerepo'),
|
||||||
project('someorg', 'somerepo'),
|
project('someorg', 'somerepo', is_org=True),
|
||||||
project('someorg', 'anotherrepo'),
|
project('someorg', 'anotherrepo', is_org=True),
|
||||||
]
|
]
|
||||||
|
|
||||||
def getproject_mock(project_name):
|
def getproject_mock(project_name):
|
||||||
|
@ -64,7 +70,7 @@ def getproject_mock(project_name):
|
||||||
return project('knownuser', 'somerepo')
|
return project('knownuser', 'somerepo')
|
||||||
|
|
||||||
if project_name == 'foo/bar':
|
if project_name == 'foo/bar':
|
||||||
return project('foo', 'bar')
|
return project('foo', 'bar', is_org=True)
|
||||||
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
Reference in a new issue