Skip to content

Commit 787b5d0

Browse files
committed
Change number int to commentID int64 in PRsService comment methods.
This is a breaking API change that is a part of issue #597. It should've been applied earlier, but we missed it because the parameter was misleadingly named number rather than id or commentID. Rename the parameter to commentID to make it more clear that it's the comment ID and not the PR ID nor PR number. This should help improve clarity of the API, and reduce the chance to mix up the IDs. Also document which PullRequestComment fields need to be set in EditComment method. Similar to #886. Updates #885. Updates #597.
1 parent 4377977 commit 787b5d0

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

github/pulls_comments.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,8 @@ func (s *PullRequestsService) ListComments(ctx context.Context, owner string, re
8787
// GetComment fetches the specified pull request comment.
8888
//
8989
// GitHub API docs: https://developer.github.com/v3/pulls/comments/#get-a-single-comment
90-
func (s *PullRequestsService) GetComment(ctx context.Context, owner string, repo string, number int) (*PullRequestComment, *Response, error) {
91-
u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, number)
90+
func (s *PullRequestsService) GetComment(ctx context.Context, owner string, repo string, commentID int64) (*PullRequestComment, *Response, error) {
91+
u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, commentID)
9292
req, err := s.client.NewRequest("GET", u, nil)
9393
if err != nil {
9494
return nil, nil, err
@@ -126,10 +126,11 @@ func (s *PullRequestsService) CreateComment(ctx context.Context, owner string, r
126126
}
127127

128128
// EditComment updates a pull request comment.
129+
// A non-nil comment.Body must be provided. Other comment fields should be left nil.
129130
//
130131
// GitHub API docs: https://developer.github.com/v3/pulls/comments/#edit-a-comment
131-
func (s *PullRequestsService) EditComment(ctx context.Context, owner string, repo string, number int, comment *PullRequestComment) (*PullRequestComment, *Response, error) {
132-
u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, number)
132+
func (s *PullRequestsService) EditComment(ctx context.Context, owner string, repo string, commentID int64, comment *PullRequestComment) (*PullRequestComment, *Response, error) {
133+
u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, commentID)
133134
req, err := s.client.NewRequest("PATCH", u, comment)
134135
if err != nil {
135136
return nil, nil, err
@@ -147,8 +148,8 @@ func (s *PullRequestsService) EditComment(ctx context.Context, owner string, rep
147148
// DeleteComment deletes a pull request comment.
148149
//
149150
// GitHub API docs: https://developer.github.com/v3/pulls/comments/#delete-a-comment
150-
func (s *PullRequestsService) DeleteComment(ctx context.Context, owner string, repo string, number int) (*Response, error) {
151-
u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, number)
151+
func (s *PullRequestsService) DeleteComment(ctx context.Context, owner string, repo string, commentID int64) (*Response, error) {
152+
u := fmt.Sprintf("repos/%v/%v/pulls/comments/%d", owner, repo, commentID)
152153
req, err := s.client.NewRequest("DELETE", u, nil)
153154
if err != nil {
154155
return nil, err

0 commit comments

Comments
 (0)