mirror of
https://github.com/woodpecker-ci/woodpecker.git
synced 2024-11-24 08:02:18 +02:00
Fix bitbucket branches pagination. (#2509)
This commit is contained in:
parent
0eacbe8a33
commit
57b7b1788d
@ -327,12 +327,12 @@ func (c *config) Netrc(u *model.User, _ *model.Repo) (*model.Netrc, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Branches returns the names of all branches for the named repository.
|
// Branches returns the names of all branches for the named repository.
|
||||||
func (c *config) Branches(ctx context.Context, u *model.User, r *model.Repo, _ *model.ListOptions) ([]string, error) {
|
func (c *config) Branches(ctx context.Context, u *model.User, r *model.Repo, p *model.ListOptions) ([]string, error) {
|
||||||
bitbucketBranches, err := c.newClient(ctx, u).ListBranches(r.Owner, r.Name)
|
opts := internal.ListOpts{Page: p.Page, PageLen: p.PerPage}
|
||||||
|
bitbucketBranches, err := c.newClient(ctx, u).ListBranches(r.Owner, r.Name, &opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
branches := make([]string, 0)
|
branches := make([]string, 0)
|
||||||
for _, branch := range bitbucketBranches {
|
for _, branch := range bitbucketBranches {
|
||||||
branches = append(branches, branch.Name)
|
branches = append(branches, branch.Name)
|
||||||
@ -347,7 +347,7 @@ func (c *config) BranchHead(ctx context.Context, u *model.User, r *model.Repo, b
|
|||||||
|
|
||||||
// PullRequests returns the pull requests of the named repository.
|
// PullRequests returns the pull requests of the named repository.
|
||||||
func (c *config) PullRequests(ctx context.Context, u *model.User, r *model.Repo, p *model.ListOptions) ([]*model.PullRequest, error) {
|
func (c *config) PullRequests(ctx context.Context, u *model.User, r *model.Repo, p *model.ListOptions) ([]*model.PullRequest, error) {
|
||||||
opts := internal.ListOpts{Page: p.Page, PageLen: p.Page}
|
opts := internal.ListOpts{Page: p.Page, PageLen: p.PerPage}
|
||||||
pullRequests, err := c.newClient(ctx, u).ListPullRequests(r.Owner, r.Name, &opts)
|
pullRequests, err := c.newClient(ctx, u).ListPullRequests(r.Owner, r.Name, &opts)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -44,7 +44,7 @@ const (
|
|||||||
pathHooks = "%s/2.0/repositories/%s/%s/hooks?%s"
|
pathHooks = "%s/2.0/repositories/%s/%s/hooks?%s"
|
||||||
pathSource = "%s/2.0/repositories/%s/%s/src/%s/%s"
|
pathSource = "%s/2.0/repositories/%s/%s/src/%s/%s"
|
||||||
pathStatus = "%s/2.0/repositories/%s/%s/commit/%s/statuses/build"
|
pathStatus = "%s/2.0/repositories/%s/%s/commit/%s/statuses/build"
|
||||||
pathBranches = "%s/2.0/repositories/%s/%s/refs/branches"
|
pathBranches = "%s/2.0/repositories/%s/%s/refs/branches?%s"
|
||||||
pathOrgPerms = "%s/2.0/workspaces/%s/permissions?%s"
|
pathOrgPerms = "%s/2.0/workspaces/%s/permissions?%s"
|
||||||
pathPullRequests = "%s/2.0/repositories/%s/%s/pullrequests"
|
pathPullRequests = "%s/2.0/repositories/%s/%s/pullrequests"
|
||||||
pathBranchCommits = "%s/2.0/repositories/%s/%s/commits/%s"
|
pathBranchCommits = "%s/2.0/repositories/%s/%s/commits/%s"
|
||||||
@ -178,9 +178,9 @@ func (c *Client) GetPermission(fullName string) (*RepoPerm, error) {
|
|||||||
return out.Values[0], nil
|
return out.Values[0], nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Client) ListBranches(owner, name string) ([]*Branch, error) {
|
func (c *Client) ListBranches(owner, name string, opts *ListOpts) ([]*Branch, error) {
|
||||||
out := new(BranchResp)
|
out := new(BranchResp)
|
||||||
uri := fmt.Sprintf(pathBranches, c.base, owner, name)
|
uri := fmt.Sprintf(pathBranches, c.base, owner, name, opts.Encode())
|
||||||
_, err := c.do(uri, get, nil, out)
|
_, err := c.do(uri, get, nil, out)
|
||||||
return out.Values, err
|
return out.Values, err
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user