From c858c3b2b8c68ec1f2b1a52dddc61653aac05fbe Mon Sep 17 00:00:00 2001 From: Brad Rydzewski Date: Wed, 3 Sep 2014 01:23:45 -0700 Subject: [PATCH] fixed issue when no gitlab permissions exist, but user is repo owner --- plugin/remote/gitlab/gitlab.go | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/plugin/remote/gitlab/gitlab.go b/plugin/remote/gitlab/gitlab.go index 120735e15..b6bd83633 100644 --- a/plugin/remote/gitlab/gitlab.go +++ b/plugin/remote/gitlab/gitlab.go @@ -83,13 +83,23 @@ func (r *Gitlab) GetRepos(user *model.User) ([]*model.Repo, error) { // if no permissions we should skip the repository // entirely, since this should never happen - if item.Permissions == nil { + if repo.Owner != user.Login && item.Permissions == nil { continue } - repo.Role.Admin = IsAdmin(item) - repo.Role.Write = IsWrite(item) - repo.Role.Read = IsRead(item) + // if the user is the owner we can assume full access, + // otherwise check for the permission items. + if repo.Owner == user.Login { + repo.Role = new(model.Perm) + repo.Role.Admin = true + repo.Role.Write = true + repo.Role.Read = true + } else { + repo.Role.Admin = IsAdmin(item) + repo.Role.Write = IsWrite(item) + repo.Role.Read = IsRead(item) + } + repos = append(repos, &repo) }