mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-23 18:31:00 +00:00
Fix gitlab permissions sync #415
This commit is contained in:
parent
446fb04d49
commit
afa928af0c
1 changed files with 11 additions and 4 deletions
|
@ -4,6 +4,7 @@ import (
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
"github.com/Bugagazavr/go-gitlab-client"
|
"github.com/Bugagazavr/go-gitlab-client"
|
||||||
"github.com/drone/drone/shared/model"
|
"github.com/drone/drone/shared/model"
|
||||||
|
@ -81,9 +82,15 @@ func (r *Gitlab) GetRepos(user *model.User) ([]*model.Repo, error) {
|
||||||
repo.CloneURL = repo.SSHURL
|
repo.CloneURL = repo.SSHURL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Fetch current project
|
||||||
|
project, err := client.Project(strconv.Itoa(item.Id))
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
// if no permissions we should skip the repository
|
// if no permissions we should skip the repository
|
||||||
// entirely, since this should never happen
|
// entirely, since this should never happen
|
||||||
if repo.Owner != user.Login && item.Permissions == nil {
|
if repo.Owner != user.Login && project.Permissions == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,9 +102,9 @@ func (r *Gitlab) GetRepos(user *model.User) ([]*model.Repo, error) {
|
||||||
repo.Role.Write = true
|
repo.Role.Write = true
|
||||||
repo.Role.Read = true
|
repo.Role.Read = true
|
||||||
} else {
|
} else {
|
||||||
repo.Role.Admin = IsAdmin(item)
|
repo.Role.Admin = IsAdmin(project)
|
||||||
repo.Role.Write = IsWrite(item)
|
repo.Role.Write = IsWrite(project)
|
||||||
repo.Role.Read = IsRead(item)
|
repo.Role.Read = IsRead(project)
|
||||||
}
|
}
|
||||||
|
|
||||||
repos = append(repos, &repo)
|
repos = append(repos, &repo)
|
||||||
|
|
Loading…
Reference in a new issue