Small fixes for GitLab trigger handler, since the GitLab API is returning the wrong ID for the user's namespace

Also has a small UI improvement
This commit is contained in:
Joseph Schorr 2018-06-13 15:12:05 -04:00
parent 0b0bd156f7
commit 63ed683dfa
3 changed files with 13 additions and 8 deletions

View file

@ -312,9 +312,14 @@ class GitLabBuildTrigger(BuildTriggerHandler):
def _get_namespace(self, gl_client, gl_namespace, lazy=False):
try:
if gl_namespace.attributes['kind'] == 'group':
return gl_client.groups.get(gl_namespace.attributes['name'], lazy=lazy)
return gl_client.groups.get(gl_namespace.attributes['id'], lazy=lazy)
return gl_client.users.get(gl_namespace.attributes['name'], lazy=lazy)
if gl_namespace.attributes['name'] == gl_client.user.attributes['username']:
return gl_client.users.get(gl_client.user.attributes['id'], lazy=lazy)
# Note: This doesn't seem to work for IDs retrieved via the namespaces API; the IDs are
# different.
return gl_client.users.get(gl_namespace.attributes['id'], lazy=lazy)
except gitlab.GitlabGetError:
return None