Skip to content

Commit

Permalink
[feat]: [CDS-73030]: checkstyle fix
Browse files Browse the repository at this point in the history
  • Loading branch information
adivishy1 committed Jul 5, 2023
1 parent 73dc4c6 commit 0c88936
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion scm/driver/azure/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion scm/driver/stash/git_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
11 changes: 7 additions & 4 deletions scm/driver/stash/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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()
}
Expand Down

0 comments on commit 0c88936

Please sign in to comment.