mirror of
https://github.com/harness/drone.git
synced 2025-05-07 00:32:56 +08:00
Added gitlab repository avatars
This commit is contained in:
parent
171b986b70
commit
c4a608b38c
@ -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"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -201,7 +206,7 @@ func (g *Gitlab) Perm(u *model.User, owner, name string) (*model.Perm, error) {
|
|||||||
|
|
||||||
// repo owner is granted full access
|
// repo owner is granted full access
|
||||||
if repo.Owner != nil && repo.Owner.Username == u.Login {
|
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
|
// check permission for current user
|
||||||
|
Loading…
Reference in New Issue
Block a user