Added gitlab repository avatars

This commit is contained in:
Kirilll Zaycev 2016-02-01 01:55:59 +03:00
parent 171b986b70
commit c4a608b38c
2 changed files with 9 additions and 3 deletions

View File

@ -48,6 +48,7 @@ type Project struct {
SshRepoUrl string `json:"ssh_url_to_repo"` SshRepoUrl string `json:"ssh_url_to_repo"`
HttpRepoUrl string `json:"http_url_to_repo"` HttpRepoUrl string `json:"http_url_to_repo"`
Url string `json:"web_url"` Url string `json:"web_url"`
AvatarUrl string `json:"avatar_url"`
Permissions *Permissions `json:"permissions,omitempty"` Permissions *Permissions `json:"permissions,omitempty"`
} }

View File

@ -173,15 +173,20 @@ func (g *Gitlab) Repos(u *model.User) ([]*model.RepoLite, error) {
var parts = strings.Split(repo.PathWithNamespace, "/") var parts = strings.Split(repo.PathWithNamespace, "/")
var owner = parts[0] var owner = parts[0]
var name = parts[1] 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{ repos = append(repos, &model.RepoLite{
Owner: owner, Owner: owner,
Name: name, Name: name,
FullName: repo.PathWithNamespace, FullName: repo.PathWithNamespace,
Avatar: avatar,
}) })
// TODO: add repo.AvatarUrl
} }
return repos, err return repos, err
} }