You've already forked woodpecker
mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2025-11-23 21:44:44 +02:00
Add PR pipeline list (#1641)
Instead of viewing PR pipelines in the branches lists, add a separate list for them. The API endpoint for PRs supports pagination (thus I added a lot of pagination-related stuff), the UI doesn't yet though.  Closes #1619 Extends this part of #1640 --------- Co-authored-by: Anbraten <anton@ju60.de>
This commit is contained in:
@@ -301,6 +301,40 @@ func (g *GitLab) Repos(ctx context.Context, user *model.User) ([]*model.Repo, er
|
||||
return repos, err
|
||||
}
|
||||
|
||||
func (g *GitLab) PullRequests(ctx context.Context, u *model.User, r *model.Repo, p *model.PaginationData) ([]*model.PullRequest, error) {
|
||||
token := ""
|
||||
if u != nil {
|
||||
token = u.Token
|
||||
}
|
||||
client, err := newClient(g.URL, token, g.SkipVerify)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
_repo, err := g.getProject(ctx, client, r.Owner, r.Name)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
state := "open"
|
||||
pullRequests, _, err := client.MergeRequests.ListProjectMergeRequests(_repo.ID, &gitlab.ListProjectMergeRequestsOptions{
|
||||
ListOptions: gitlab.ListOptions{Page: int(p.Page), PerPage: int(p.PerPage)},
|
||||
State: &state,
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
result := make([]*model.PullRequest, len(pullRequests))
|
||||
for i := range pullRequests {
|
||||
result[i] = &model.PullRequest{
|
||||
Index: int64(pullRequests[i].ID),
|
||||
Title: pullRequests[i].Title,
|
||||
}
|
||||
}
|
||||
return result, err
|
||||
}
|
||||
|
||||
// Perm fetches the named repository from the forge.
|
||||
func (g *GitLab) Perm(ctx context.Context, user *model.User, r *model.Repo) (*model.Perm, error) {
|
||||
client, err := newClient(g.URL, user.Token, g.SkipVerify)
|
||||
|
||||
Reference in New Issue
Block a user