1
0
mirror of https://github.com/woodpecker-ci/woodpecker.git synced 2024-11-30 08:06:52 +02:00

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"`
HttpRepoUrl string `json:"http_url_to_repo"`
Url string `json:"web_url"`
AvatarUrl string `json:"avatar_url"`
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 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