diff --git a/scm/driver/azure/git.go b/scm/driver/azure/git.go index a487680c..af6656c1 100644 --- a/scm/driver/azure/git.go +++ b/scm/driver/azure/git.go @@ -52,7 +52,7 @@ func (s *gitService) FindTag(ctx context.Context, repo, name string) (*scm.Refer return nil, nil, scm.ErrNotSupported } -func (s *gitService) ListBranches(ctx context.Context, repo string, opts scm.ListOptions) ([]*scm.Reference, *scm.Response, error) { +func (s *gitService) ListBranches(ctx context.Context, repo string, _ scm.ListOptions) ([]*scm.Reference, *scm.Response, error) { // https://docs.microsoft.com/en-us/rest/api/azure/devops/git/refs/list?view=azure-devops-rest-6.0 if s.client.project == "" { return nil, nil, ProjectRequiredError() diff --git a/scm/driver/stash/git_test.go b/scm/driver/stash/git_test.go index fec3b44e..720e8fa6 100644 --- a/scm/driver/stash/git_test.go +++ b/scm/driver/stash/git_test.go @@ -124,7 +124,7 @@ func TestGitListBranches(t *testing.T) { gock.New("http://example.com:7990"). Get("/rest/api/1.0/projects/PRJ/repos/my-repo/branches"). - MatchParam("pagelen", "30"). + MatchParam("limit", "30"). Reply(200). Type("application/json"). File("testdata/branches.json") diff --git a/scm/driver/stash/util.go b/scm/driver/stash/util.go index 09646598..0de82e3f 100644 --- a/scm/driver/stash/util.go +++ b/scm/driver/stash/util.go @@ -6,9 +6,10 @@ package stash import ( "errors" - "github.com/drone/go-scm/scm" "net/url" "strconv" + + "github.com/drone/go-scm/scm" ) func encodeListOptions(opts scm.ListOptions) string { @@ -29,11 +30,13 @@ func encodeBranchListOptions(opts scm.BranchListOptions) string { if opts.SearchTerm != "" { params.Set("filterText", opts.SearchTerm) } - if opts.PageListOptions.Page != 0 { - params.Set("page", strconv.Itoa(opts.PageListOptions.Page)) + if opts.PageListOptions.Page > 1 { + params.Set("start", strconv.Itoa( + (opts.PageListOptions.Page-1)*opts.PageListOptions.Size), + ) } if opts.PageListOptions.Size != 0 { - params.Set("pagelen", strconv.Itoa(opts.PageListOptions.Size)) + params.Set("limit", strconv.Itoa(opts.PageListOptions.Size)) } return params.Encode() }