Skip to content

Commit

Permalink
Merge pull request runatlantis#371 from runatlantis/bitbucket-cloud-api
Browse files Browse the repository at this point in the history
Use Bitbucket 2.0 API for comments.
  • Loading branch information
lkysow authored Dec 4, 2018
2 parents 387186e + b13a85b commit 521b509
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions server/events/vcs/bitbucketcloud/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,11 +86,16 @@ func (b *Client) GetModifiedFiles(repo models.Repo, pull models.PullRequest) ([]

// CreateComment creates a comment on the merge request.
func (b *Client) CreateComment(repo models.Repo, pullNum int, comment string) error {
bodyBytes, err := json.Marshal(map[string]string{"content": comment})
// NOTE: I tried to find the maximum size of a comment for bitbucket.org but
// I got up to 200k chars without issue so for now I'm not going to bother
// to detect this.
bodyBytes, err := json.Marshal(map[string]map[string]string{"content": {
"raw": comment,
}})
if err != nil {
return errors.Wrap(err, "json encoding")
}
path := fmt.Sprintf("%s/1.0/repositories/%s/pullrequests/%d/comments", b.BaseURL, repo.FullName, pullNum)
path := fmt.Sprintf("%s/2.0/repositories/%s/pullrequests/%d/comments", b.BaseURL, repo.FullName, pullNum)
_, err = b.makeRequest("POST", path, bytes.NewBuffer(bodyBytes))
return err
}
Expand Down

0 comments on commit 521b509

Please sign in to comment.