From c4a608b38c4609be62ced84c7691bf4c6da40d73 Mon Sep 17 00:00:00 2001 From: Kirilll Zaycev Date: Mon, 1 Feb 2016 01:55:59 +0300 Subject: [PATCH] Added gitlab repository avatars --- remote/gitlab/client/types.go | 1 + remote/gitlab/gitlab.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/remote/gitlab/client/types.go b/remote/gitlab/client/types.go index d89311a27..dbd3db977 100644 --- a/remote/gitlab/client/types.go +++ b/remote/gitlab/client/types.go @@ -48,6 +48,7 @@ type Project struct { SshRepoUrl string `json:"ssh_url_to_repo"` HttpRepoUrl string `json:"http_url_to_repo"` Url string `json:"web_url"` + AvatarUrl string `json:"avatar_url"` Permissions *Permissions `json:"permissions,omitempty"` } diff --git a/remote/gitlab/gitlab.go b/remote/gitlab/gitlab.go index 026a63de1..faf473c95 100644 --- a/remote/gitlab/gitlab.go +++ b/remote/gitlab/gitlab.go @@ -173,15 +173,20 @@ func (g *Gitlab) Repos(u *model.User) ([]*model.RepoLite, error) { var parts = strings.Split(repo.PathWithNamespace, "/") var owner = parts[0] var name = parts[1] + var avatar = repo.AvatarUrl + + if len(avatar) != 0 && !strings.HasPrefix(avatar, "http") { + avatar = fmt.Sprintf("%s/%s", g.URL, avatar) + } repos = append(repos, &model.RepoLite{ Owner: owner, Name: name, FullName: repo.PathWithNamespace, + Avatar: avatar, }) - - // TODO: add repo.AvatarUrl } + return repos, err } @@ -201,7 +206,7 @@ func (g *Gitlab) Perm(u *model.User, owner, name string) (*model.Perm, error) { // repo owner is granted full access if repo.Owner != nil && repo.Owner.Username == u.Login { - return &model.Perm{true, true, true}, nil + return &model.Perm{true, true, true}, nil } // check permission for current user