Skip to content

Commit

Permalink
Merge pull request #354 from runatlantis/bitbucket-nextpagestart
Browse files Browse the repository at this point in the history
Use int instead of string for bitbucket response.
  • Loading branch information
lkysow authored Nov 17, 2018
2 parents b63f569 + deebb22 commit c6dcd65
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions server/events/vcs/bitbucketserver/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ func (b *Client) GetModifiedFiles(repo models.Repo, pull models.PullRequest) ([]
if err != nil {
return nil, err
}
nextPageStart := "0"
nextPageStart := 0
baseURL := fmt.Sprintf("%s/rest/api/1.0/projects/%s/repos/%s/pull-requests/%d/changes",
b.BaseURL, projectKey, repo.Name, pull.Num)
// We'll only loop 1000 times as a safety measure.
maxLoops := 1000
for i := 0; i < maxLoops; i++ {
resp, err := b.makeRequest("GET", fmt.Sprintf("%s?start=%s", baseURL, nextPageStart), nil)
resp, err := b.makeRequest("GET", fmt.Sprintf("%s?start=%d", baseURL, nextPageStart), nil)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion server/events/vcs/bitbucketserver/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func TestClient_GetModifiedFilesPagination(t *testing.T) {
// The first request should hit this URL.
case "/rest/api/1.0/projects/ow/repos/repo/pull-requests/1/changes?start=0":
resp := strings.Replace(firstResp, `"isLastPage": true`, `"isLastPage": false`, -1)
resp = strings.Replace(resp, `"nextPageStart": null`, `"nextPageStart": "3"`, -1)
resp = strings.Replace(resp, `"nextPageStart": null`, `"nextPageStart": 3`, -1)
w.Write([]byte(resp)) // nolint: errcheck
return
// The second should hit this URL.
Expand Down
4 changes: 2 additions & 2 deletions server/events/vcs/bitbucketserver/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,6 @@ type Changes struct {
ToString *string `json:"toString,omitempty" validate:"required"`
} `json:"path,omitempty" validate:"required"`
} `json:"values,omitempty" validate:"required"`
NextPageStart *string `json:"nextPageStart,omitempty"`
IsLastPage *bool `json:"isLastPage,omitempty" validate:"required"`
NextPageStart *int `json:"nextPageStart,omitempty"`
IsLastPage *bool `json:"isLastPage,omitempty" validate:"required"`
}

0 comments on commit c6dcd65

Please sign in to comment.