Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use int instead of string for bitbucket response. #354

Merged
merged 1 commit into from
Nov 17, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"`
}