From 354caf491e3d67947996b65b9bc01344a8282b9f Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Sat, 17 Dec 2016 00:18:18 +0100 Subject: [PATCH 01/22] Add 'list all reviews' endpoint from new pull request review API This commit adds only one of the total 6 endpoints made available for developers preview. Partly fixes #495 EDIT: Fix minor things based on initial review. --- github/github.go | 3 +++ github/pulls_reviews.go | 45 +++++++++++++++++++++++++++++++----- github/pulls_reviews_test.go | 37 +++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 6 deletions(-) create mode 100644 github/pulls_reviews_test.go diff --git a/github/github.go b/github/github.go index 6d4e7775798..a58dbfb58d4 100644 --- a/github/github.go +++ b/github/github.go @@ -96,6 +96,9 @@ const ( // https://developer.github.com/changes/2017-01-05-commit-search-api/ mediaTypeCommitSearchPreview = "application/vnd.github.cloak-preview+json" + + // https://developer.github.com/changes/2016-12-14-reviews-api/ + mediaTypePullRequestReviewsPreview = "application/vnd.github.black-cat-preview+json" ) // A Client manages communication with the GitHub API. diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index ae3cdd4af42..ded95ca2245 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -5,15 +5,48 @@ package github -import "time" +import ( + "fmt" + "time" +) // PullRequestReview represents a review of a pull request. type PullRequestReview struct { - ID *int `json:"id,omitempty"` - User *User `json:"user,omitempty"` - Body *string `json:"body,omitempty"` - SubmittedAt *time.Time `json:"submitted_at,omitempty"` + ID *int `json:"id,omitempty"` + User *User `json:"user,omitempty"` + Body *string `json:"body,omitempty"` + SubmittedAt *time.Time `json:"submitted_at,omitempty"` + CommitID *string `json:"commit_id,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + PullRequestURL *string `json:"pull_request_url,omitempty"` - // State can be "approved", "rejected", or "commented". + // State can be "ACCEPTED", "DISMISSED", "CHANGES_REQUESTED" or "COMMENTED". State *string `json:"state,omitempty"` } + +func (p PullRequestReview) String() string { + return Stringify(p) +} + +// ListReviews lists all reviews on the specified pull request. +// +// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request +func (s *PullRequestsService) ListReviews(owner string, repo string, number int) ([]*PullRequestReview, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews", owner, repo, number) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches + req.Header.Set("Accept", mediaTypePullRequestReviewsPreview) + + reviews := new([]*PullRequestReview) + resp, err := s.client.Do(req, reviews) + if err != nil { + return nil, resp, err + } + + return *reviews, resp, err +} diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go new file mode 100644 index 00000000000..cd40d1d5dd8 --- /dev/null +++ b/github/pulls_reviews_test.go @@ -0,0 +1,37 @@ +// Copyright 2016 The go-github AUTHORS. All rights reserved. +// +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +package github + +import ( + "fmt" + "net/http" + "reflect" + "testing" +) + +func TestPullRequestsService_ListReviews(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/repos/o/r/pulls/1/reviews", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview) + fmt.Fprint(w, `[{"id":1},{"id":2}]`) + }) + + reviews, _, err := client.PullRequests.ListReviews("o", "r", 1) + if err != nil { + t.Errorf("PullRequests.ListReviews returned error: %v", err) + } + + want := []*PullRequestReview{ + {ID: Int(1)}, + {ID: Int(2)}, + } + if !reflect.DeepEqual(reviews, want) { + t.Errorf("PullRequests.ListReviews returned %+v, want %+v", reviews, want) + } +} From 36c6f8c04a363d7e1adfead7b80d2f8977086e76 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Sat, 17 Dec 2016 20:29:08 +0100 Subject: [PATCH 02/22] Add GetReview and ListReviewComments methods to PullRequest - Added GetReview method to get a particular review and also added tests. - Added ListReviewComments method to list all comments for a particular review and also added tests for the same. --- github/pulls_reviews.go | 58 ++++++++++++++++++++++++++++++++++++ github/pulls_reviews_test.go | 45 ++++++++++++++++++++++++++++ 2 files changed, 103 insertions(+) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index ded95ca2245..bf6cd057c75 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -24,6 +24,18 @@ type PullRequestReview struct { State *string `json:"state,omitempty"` } +// PullRequestReviewComment represents a comment left on a pull request review +type PullRequestReviewComment struct { + ID *int `json:"id,omitempty"` + User *User `json:"user,omitempty"` + Body *string `json:"body,omitempty"` + CreatedAt *time.Time `json:"created_at,omitempty"` + UpdatedAt *time.Time `json:"updated_at,omitempty"` + CommitID *string `json:"commit_id,omitempty"` + HTMLURL *string `json:"html_url,omitempty"` + PullRequestURL *string `json:"pull_request_url,omitempty"` +} + func (p PullRequestReview) String() string { return Stringify(p) } @@ -50,3 +62,49 @@ func (s *PullRequestsService) ListReviews(owner string, repo string, number int) return *reviews, resp, err } + +// GetReview fetches the specified pull request review. +// +// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-review +func (s *PullRequestsService) GetReview(owner string, number int, id int) (*PullRequestReview, *Response, error) { + u := fmt.Sprintf("repos/%v/pulls/%d/reviews/%d", owner, number, id) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches + req.Header.Set("Accept", mediaTypePullRequestReviewsPreview) + + review := new(PullRequestReview) + resp, err := s.client.Do(req, review) + if err != nil { + return nil, resp, err + } + + return review, resp, err +} + +// ListReviewComments lists all the comments for the specified review +// +// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-reviews-comments +func (s *PullRequestsService) ListReviewComments(owner string, number int, id int) ([]*PullRequestReviewComment, *Response, error) { + u := fmt.Sprintf("repos/%v/pulls/%d/reviews/%d/comments", owner, number, id) + + req, err := s.client.NewRequest("GET", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches + req.Header.Set("Accept", mediaTypePullRequestReviewsPreview) + + comments := new([]*PullRequestReviewComment) + resp, err := s.client.Do(req, comments) + if err != nil { + return nil, resp, err + } + + return *comments, resp, err +} diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index cd40d1d5dd8..d71766f7c18 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -35,3 +35,48 @@ func TestPullRequestsService_ListReviews(t *testing.T) { t.Errorf("PullRequests.ListReviews returned %+v, want %+v", reviews, want) } } + +func TestPullRequestsService_GetReview(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/repos/o/pulls/1/reviews/1", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview) + fmt.Fprint(w, `{"id":1}`) + }) + + review, _, err := client.PullRequests.GetReview("o", 1, 1) + if err != nil { + t.Errorf("PullRequests.GetReview returned error: %v", err) + } + + want := &PullRequestReview{ID: Int(1)} + if !reflect.DeepEqual(review, want) { + t.Errorf("PullRequests.GetReview returned %+v, want %+v", review, want) + } +} + +func TestPullRequestsService_ListReviewComments(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/repos/o/pulls/1/reviews/1/comments", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "GET") + testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview) + fmt.Fprint(w, `[{"id":1},{"id":2}]`) + }) + + comments, _, err := client.PullRequests.ListReviewComments("o", 1, 1) + if err != nil { + t.Errorf("PullRequests.ListReviewComments returned error: %v", err) + } + + want := []*PullRequestReviewComment{ + {ID: Int(1)}, + {ID: Int(2)}, + } + if !reflect.DeepEqual(comments, want) { + t.Errorf("PullRequests.ListReviewComments returned %+v, want %+v", comments, want) + } +} From a8392c446ae687cdc1e377eae92b74416612556e Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Sun, 18 Dec 2016 00:42:53 +0100 Subject: [PATCH 03/22] Update GetReview and ListReviewComments to include repo param There is an error in GitHub documentation at the moment. They haven't mentioned the repo param in the endpoint illustration. However, the API gives 404 if we don't pass repo name. --- github/pulls_reviews.go | 8 ++++---- github/pulls_reviews_test.go | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index bf6cd057c75..fb47dd1a34c 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -66,8 +66,8 @@ func (s *PullRequestsService) ListReviews(owner string, repo string, number int) // GetReview fetches the specified pull request review. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-review -func (s *PullRequestsService) GetReview(owner string, number int, id int) (*PullRequestReview, *Response, error) { - u := fmt.Sprintf("repos/%v/pulls/%d/reviews/%d", owner, number, id) +func (s *PullRequestsService) GetReview(owner string, repo string, number int, id int) (*PullRequestReview, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, id) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -89,8 +89,8 @@ func (s *PullRequestsService) GetReview(owner string, number int, id int) (*Pull // ListReviewComments lists all the comments for the specified review // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-reviews-comments -func (s *PullRequestsService) ListReviewComments(owner string, number int, id int) ([]*PullRequestReviewComment, *Response, error) { - u := fmt.Sprintf("repos/%v/pulls/%d/reviews/%d/comments", owner, number, id) +func (s *PullRequestsService) ListReviewComments(owner string, repo string, number int, id int) ([]*PullRequestReviewComment, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/comments", owner, repo, number, id) req, err := s.client.NewRequest("GET", u, nil) if err != nil { diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index d71766f7c18..74f3519d04a 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -40,13 +40,13 @@ func TestPullRequestsService_GetReview(t *testing.T) { setup() defer teardown() - mux.HandleFunc("/repos/o/pulls/1/reviews/1", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/pulls/1/reviews/1", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview) fmt.Fprint(w, `{"id":1}`) }) - review, _, err := client.PullRequests.GetReview("o", 1, 1) + review, _, err := client.PullRequests.GetReview("o", "r", 1, 1) if err != nil { t.Errorf("PullRequests.GetReview returned error: %v", err) } @@ -61,13 +61,13 @@ func TestPullRequestsService_ListReviewComments(t *testing.T) { setup() defer teardown() - mux.HandleFunc("/repos/o/pulls/1/reviews/1/comments", func(w http.ResponseWriter, r *http.Request) { + mux.HandleFunc("/repos/o/r/pulls/1/reviews/1/comments", func(w http.ResponseWriter, r *http.Request) { testMethod(t, r, "GET") testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview) fmt.Fprint(w, `[{"id":1},{"id":2}]`) }) - comments, _, err := client.PullRequests.ListReviewComments("o", 1, 1) + comments, _, err := client.PullRequests.ListReviewComments("o", "r", 1, 1) if err != nil { t.Errorf("PullRequests.ListReviewComments returned error: %v", err) } From 1ce35182832674605c6bbab762e95ff8a47f72c9 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Sun, 18 Dec 2016 01:00:26 +0100 Subject: [PATCH 04/22] Add CreateReview method to PullRequest service - Added CreateReview method to create a review on the specified pull request - Also added test for the same. --- github/pulls_reviews.go | 23 +++++++++++++++++++++++ github/pulls_reviews_test.go | 31 +++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index fb47dd1a34c..e42255a7466 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -108,3 +108,26 @@ func (s *PullRequestsService) ListReviewComments(owner string, repo string, numb return *comments, resp, err } + +// CreateReview creates a new review on the specified pull request +// +// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review +func (s *PullRequestsService) CreateReview(owner string, repo string, number int, review *PullRequestReview) (*PullRequestReview, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews", owner, repo, number) + + req, err := s.client.NewRequest("POST", u, review) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches + req.Header.Set("Accept", mediaTypePullRequestReviewsPreview) + + r := new(PullRequestReview) + resp, err := s.client.Do(req, r) + if err != nil { + return nil, resp, err + } + + return r, resp, err +} diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index 74f3519d04a..efa925e54a8 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -6,6 +6,7 @@ package github import ( + "encoding/json" "fmt" "net/http" "reflect" @@ -80,3 +81,33 @@ func TestPullRequestsService_ListReviewComments(t *testing.T) { t.Errorf("PullRequests.ListReviewComments returned %+v, want %+v", comments, want) } } + +func TestPullRequestsService_CreateReview(t *testing.T) { + setup() + defer teardown() + + input := &PullRequestReview{Body: String("b")} + + mux.HandleFunc("/repos/o/r/pulls/1/reviews", func(w http.ResponseWriter, r *http.Request) { + v := new(PullRequestReview) + json.NewDecoder(r.Body).Decode(v) + + testMethod(t, r, "POST") + testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview) + if !reflect.DeepEqual(v, input) { + t.Errorf("Request body = %+v, want %+v", v, input) + } + + fmt.Fprint(w, `{"id":1}`) + }) + + review, _, err := client.PullRequests.CreateReview("o", "r", 1, input) + if err != nil { + t.Errorf("PullRequests.CreateReview returned error: %v", err) + } + + want := &PullRequestReview{ID: Int(1)} + if !reflect.DeepEqual(review, want) { + t.Errorf("PullRequests.CreateReview returned %+v, want %+v", review, want) + } +} From 51826781bee1a818c1f089b8273c02c13ef32d36 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Sun, 18 Dec 2016 02:02:09 +0100 Subject: [PATCH 05/22] Modify CreateReview to add PullRequestReviewRequest struct - Added DraftReviewComment struct which represents a comment part of the review - Added PullRequestReviewRequest struct which has Body, Event and a list of DraftReviewComment structs --- github/pulls_reviews.go | 20 +++++++++++++++++--- github/pulls_reviews_test.go | 7 +++++-- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index e42255a7466..0345b9e12b3 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -24,6 +24,10 @@ type PullRequestReview struct { State *string `json:"state,omitempty"` } +func (p PullRequestReview) String() string { + return Stringify(p) +} + // PullRequestReviewComment represents a comment left on a pull request review type PullRequestReviewComment struct { ID *int `json:"id,omitempty"` @@ -36,8 +40,18 @@ type PullRequestReviewComment struct { PullRequestURL *string `json:"pull_request_url,omitempty"` } -func (p PullRequestReview) String() string { - return Stringify(p) +// DraftReviewComment represents a comment part of the review +type DraftReviewComment struct { + Path *string `json:"path,omitempty"` + Position *int `json:"position,omitempty"` + Body *string `json:"body,omitempty"` +} + +// PullRequestReviewRequest represents a request to create a review +type PullRequestReviewRequest struct { + Body *string `json:"body,omitempty"` + Event *string `json:"event,omitempty"` + Comments []DraftReviewComment `json:"comments",omitempty"` } // ListReviews lists all reviews on the specified pull request. @@ -112,7 +126,7 @@ func (s *PullRequestsService) ListReviewComments(owner string, repo string, numb // CreateReview creates a new review on the specified pull request // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review -func (s *PullRequestsService) CreateReview(owner string, repo string, number int, review *PullRequestReview) (*PullRequestReview, *Response, error) { +func (s *PullRequestsService) CreateReview(owner string, repo string, number int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews", owner, repo, number) req, err := s.client.NewRequest("POST", u, review) diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index efa925e54a8..aa62b24f9db 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -86,10 +86,13 @@ func TestPullRequestsService_CreateReview(t *testing.T) { setup() defer teardown() - input := &PullRequestReview{Body: String("b")} + input := &PullRequestReviewRequest{ + Body: String("b"), + Event: String("APPROVE"), + } mux.HandleFunc("/repos/o/r/pulls/1/reviews", func(w http.ResponseWriter, r *http.Request) { - v := new(PullRequestReview) + v := new(PullRequestReviewRequest) json.NewDecoder(r.Body).Decode(v) testMethod(t, r, "POST") From 178c4edd2832225a831269aef0e343c1bc0c9b03 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Sun, 18 Dec 2016 02:12:29 +0100 Subject: [PATCH 06/22] Add SubmitReview method to PullRequest service Also fixed syntax error for struct pair in DraftReviewComment struct. --- github/pulls_reviews.go | 25 ++++++++++++++++++++++++- github/pulls_reviews_test.go | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index 0345b9e12b3..f6acf282fb8 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -51,7 +51,7 @@ type DraftReviewComment struct { type PullRequestReviewRequest struct { Body *string `json:"body,omitempty"` Event *string `json:"event,omitempty"` - Comments []DraftReviewComment `json:"comments",omitempty"` + Comments []DraftReviewComment `json:"comments,omitempty"` } // ListReviews lists all reviews on the specified pull request. @@ -145,3 +145,26 @@ func (s *PullRequestsService) CreateReview(owner string, repo string, number int return r, resp, err } + +// SubmitReview creates a new review on the specified pull request +// +// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review +func (s *PullRequestsService) SubmitReview(owner string, repo string, number int, id int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/events", owner, repo, number, id) + + req, err := s.client.NewRequest("POST", u, review) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches + req.Header.Set("Accept", mediaTypePullRequestReviewsPreview) + + r := new(PullRequestReview) + resp, err := s.client.Do(req, r) + if err != nil { + return nil, resp, err + } + + return r, resp, err +} diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index aa62b24f9db..5f610056ee1 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -114,3 +114,36 @@ func TestPullRequestsService_CreateReview(t *testing.T) { t.Errorf("PullRequests.CreateReview returned %+v, want %+v", review, want) } } + +func TestPullRequestsService_SubmitReview(t *testing.T) { + setup() + defer teardown() + + input := &PullRequestReviewRequest{ + Body: String("b"), + Event: String("APPROVE"), + } + + mux.HandleFunc("/repos/o/r/pulls/1/reviews/1/events", func(w http.ResponseWriter, r *http.Request) { + v := new(PullRequestReviewRequest) + json.NewDecoder(r.Body).Decode(v) + + testMethod(t, r, "POST") + testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview) + if !reflect.DeepEqual(v, input) { + t.Errorf("Request body = %+v, want %+v", v, input) + } + + fmt.Fprint(w, `{"id":1}`) + }) + + review, _, err := client.PullRequests.SubmitReview("o", "r", 1, 1, input) + if err != nil { + t.Errorf("PullRequests.SubmitReview returned error: %v", err) + } + + want := &PullRequestReview{ID: Int(1)} + if !reflect.DeepEqual(review, want) { + t.Errorf("PullRequests.SubmitReview returned %+v, want %+v", review, want) + } +} From a8df51b9d32f3b87268c8aa0602074da9a645fb8 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Sun, 18 Dec 2016 02:32:35 +0100 Subject: [PATCH 07/22] Fix minor typos related to SubmitReview method --- github/pulls_reviews.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index f6acf282fb8..f64b7e49896 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -146,9 +146,9 @@ func (s *PullRequestsService) CreateReview(owner string, repo string, number int return r, resp, err } -// SubmitReview creates a new review on the specified pull request +// SubmitReview submits a review on the specified pull request // -// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review +// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#submit-a-pull-request-review func (s *PullRequestsService) SubmitReview(owner string, repo string, number int, id int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/events", owner, repo, number, id) From cd49c5ca1af7eea848d1387e21ee0d6bece50c6c Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Sun, 18 Dec 2016 02:45:17 +0100 Subject: [PATCH 08/22] Add DismissReview method to PullRequest service Added another parameter message in PullRequestReviewRequest instead of adding a new struct like PullRequestReviewDismissRequest. --- github/pulls_reviews.go | 28 +++++++++++++++++++++++++++- github/pulls_reviews_test.go | 30 ++++++++++++++++++++++++++++++ 2 files changed, 57 insertions(+), 1 deletion(-) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index f64b7e49896..cece874e4ab 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -52,6 +52,9 @@ type PullRequestReviewRequest struct { Body *string `json:"body,omitempty"` Event *string `json:"event,omitempty"` Comments []DraftReviewComment `json:"comments,omitempty"` + + // Message is used (optionally) while dismissing a review + Message *string `json:"message,omitempty"` } // ListReviews lists all reviews on the specified pull request. @@ -146,7 +149,7 @@ func (s *PullRequestsService) CreateReview(owner string, repo string, number int return r, resp, err } -// SubmitReview submits a review on the specified pull request +// SubmitReview submits a specified review on the specified pull request // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#submit-a-pull-request-review func (s *PullRequestsService) SubmitReview(owner string, repo string, number int, id int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { @@ -168,3 +171,26 @@ func (s *PullRequestsService) SubmitReview(owner string, repo string, number int return r, resp, err } + +// DismissReview dismisses a specified review on the specified pull request +// +// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#dismiss-a-pull-request-review +func (s *PullRequestsService) DismissReview(owner string, repo string, number int, id int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/dismissals", owner, repo, number, id) + + req, err := s.client.NewRequest("PUT", u, review) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches + req.Header.Set("Accept", mediaTypePullRequestReviewsPreview) + + r := new(PullRequestReview) + resp, err := s.client.Do(req, r) + if err != nil { + return nil, resp, err + } + + return r, resp, err +} diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index 5f610056ee1..05f8c2cd1fd 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -147,3 +147,33 @@ func TestPullRequestsService_SubmitReview(t *testing.T) { t.Errorf("PullRequests.SubmitReview returned %+v, want %+v", review, want) } } + +func TestPullRequestsService_DismissReview(t *testing.T) { + setup() + defer teardown() + + input := &PullRequestReviewRequest{Message: String("m")} + + mux.HandleFunc("/repos/o/r/pulls/1/reviews/1/dismissals", func(w http.ResponseWriter, r *http.Request) { + v := new(PullRequestReviewRequest) + json.NewDecoder(r.Body).Decode(v) + + testMethod(t, r, "PUT") + testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview) + if !reflect.DeepEqual(v, input) { + t.Errorf("Request body = %+v, want %+v", v, input) + } + + fmt.Fprint(w, `{"id":1}`) + }) + + review, _, err := client.PullRequests.DismissReview("o", "r", 1, 1, input) + if err != nil { + t.Errorf("PullRequests.DismissReview returned error: %v", err) + } + + want := &PullRequestReview{ID: Int(1)} + if !reflect.DeepEqual(review, want) { + t.Errorf("PullRequests.DismissReview returned %+v, want %+v", review, want) + } +} From 167e2170b294d32ecb51297c26c36c405ccb498b Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Sun, 18 Dec 2016 03:14:34 +0100 Subject: [PATCH 09/22] Fix minor formatting issue with gofmt --- github/pulls_reviews.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index cece874e4ab..56fbea4ee79 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -54,7 +54,7 @@ type PullRequestReviewRequest struct { Comments []DraftReviewComment `json:"comments,omitempty"` // Message is used (optionally) while dismissing a review - Message *string `json:"message,omitempty"` + Message *string `json:"message,omitempty"` } // ListReviews lists all reviews on the specified pull request. From 99df209a8f021953e125c12f6c3b3bbfef445c06 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Thu, 22 Dec 2016 00:21:42 +0100 Subject: [PATCH 10/22] Create new struct PullRequestReveiwDismissalRequest --- github/pulls_reviews.go | 20 +++++++++++--------- github/pulls_reviews_test.go | 4 ++-- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index 56fbea4ee79..8c6b44a1f8e 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -28,7 +28,7 @@ func (p PullRequestReview) String() string { return Stringify(p) } -// PullRequestReviewComment represents a comment left on a pull request review +// PullRequestReviewComment represents a comment left on a pull request review. type PullRequestReviewComment struct { ID *int `json:"id,omitempty"` User *User `json:"user,omitempty"` @@ -40,20 +40,22 @@ type PullRequestReviewComment struct { PullRequestURL *string `json:"pull_request_url,omitempty"` } -// DraftReviewComment represents a comment part of the review +// DraftReviewComment represents a comment part of the review. type DraftReviewComment struct { Path *string `json:"path,omitempty"` Position *int `json:"position,omitempty"` Body *string `json:"body,omitempty"` } -// PullRequestReviewRequest represents a request to create a review +// PullRequestReviewRequest represents a request to create a review. type PullRequestReviewRequest struct { Body *string `json:"body,omitempty"` Event *string `json:"event,omitempty"` Comments []DraftReviewComment `json:"comments,omitempty"` +} - // Message is used (optionally) while dismissing a review +// PullRequestReviewDismissalRequest represents a request to dismiss a review. +type PullRequestReviewDismissalRequest struct { Message *string `json:"message,omitempty"` } @@ -103,7 +105,7 @@ func (s *PullRequestsService) GetReview(owner string, repo string, number int, i return review, resp, err } -// ListReviewComments lists all the comments for the specified review +// ListReviewComments lists all the comments for the specified review. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-reviews-comments func (s *PullRequestsService) ListReviewComments(owner string, repo string, number int, id int) ([]*PullRequestReviewComment, *Response, error) { @@ -126,7 +128,7 @@ func (s *PullRequestsService) ListReviewComments(owner string, repo string, numb return *comments, resp, err } -// CreateReview creates a new review on the specified pull request +// CreateReview creates a new review on the specified pull request. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review func (s *PullRequestsService) CreateReview(owner string, repo string, number int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { @@ -149,7 +151,7 @@ func (s *PullRequestsService) CreateReview(owner string, repo string, number int return r, resp, err } -// SubmitReview submits a specified review on the specified pull request +// SubmitReview submits a specified review on the specified pull request. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#submit-a-pull-request-review func (s *PullRequestsService) SubmitReview(owner string, repo string, number int, id int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { @@ -172,10 +174,10 @@ func (s *PullRequestsService) SubmitReview(owner string, repo string, number int return r, resp, err } -// DismissReview dismisses a specified review on the specified pull request +// DismissReview dismisses a specified review on the specified pull request. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#dismiss-a-pull-request-review -func (s *PullRequestsService) DismissReview(owner string, repo string, number int, id int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { +func (s *PullRequestsService) DismissReview(owner string, repo string, number int, id int, review *PullRequestReviewDismissalRequest) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/dismissals", owner, repo, number, id) req, err := s.client.NewRequest("PUT", u, review) diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index 05f8c2cd1fd..c1663a378ad 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -152,10 +152,10 @@ func TestPullRequestsService_DismissReview(t *testing.T) { setup() defer teardown() - input := &PullRequestReviewRequest{Message: String("m")} + input := &PullRequestReviewDismissalRequest{Message: String("m")} mux.HandleFunc("/repos/o/r/pulls/1/reviews/1/dismissals", func(w http.ResponseWriter, r *http.Request) { - v := new(PullRequestReviewRequest) + v := new(PullRequestReviewDismissalRequest) json.NewDecoder(r.Body).Decode(v) testMethod(t, r, "PUT") From c60f5b34b7f1560b3a15d740fa42708e3ee4f9cd Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Thu, 22 Dec 2016 00:23:10 +0100 Subject: [PATCH 11/22] Rename 'id' param to 'reviewID' to make it more verbose --- github/pulls_reviews.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index 8c6b44a1f8e..db82b726465 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -85,8 +85,8 @@ func (s *PullRequestsService) ListReviews(owner string, repo string, number int) // GetReview fetches the specified pull request review. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-review -func (s *PullRequestsService) GetReview(owner string, repo string, number int, id int) (*PullRequestReview, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, id) +func (s *PullRequestsService) GetReview(owner string, repo string, number int, reviewID int) (*PullRequestReview, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, reviewID) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -108,8 +108,8 @@ func (s *PullRequestsService) GetReview(owner string, repo string, number int, i // ListReviewComments lists all the comments for the specified review. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-reviews-comments -func (s *PullRequestsService) ListReviewComments(owner string, repo string, number int, id int) ([]*PullRequestReviewComment, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/comments", owner, repo, number, id) +func (s *PullRequestsService) ListReviewComments(owner string, repo string, number int, reviewID int) ([]*PullRequestReviewComment, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/comments", owner, repo, number, reviewID) req, err := s.client.NewRequest("GET", u, nil) if err != nil { @@ -154,8 +154,8 @@ func (s *PullRequestsService) CreateReview(owner string, repo string, number int // SubmitReview submits a specified review on the specified pull request. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#submit-a-pull-request-review -func (s *PullRequestsService) SubmitReview(owner string, repo string, number int, id int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/events", owner, repo, number, id) +func (s *PullRequestsService) SubmitReview(owner string, repo string, number int, reviewID int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/events", owner, repo, number, reviewID) req, err := s.client.NewRequest("POST", u, review) if err != nil { @@ -177,8 +177,8 @@ func (s *PullRequestsService) SubmitReview(owner string, repo string, number int // DismissReview dismisses a specified review on the specified pull request. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#dismiss-a-pull-request-review -func (s *PullRequestsService) DismissReview(owner string, repo string, number int, id int, review *PullRequestReviewDismissalRequest) (*PullRequestReview, *Response, error) { - u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/dismissals", owner, repo, number, id) +func (s *PullRequestsService) DismissReview(owner string, repo string, number int, reviewID int, review *PullRequestReviewDismissalRequest) (*PullRequestReview, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/dismissals", owner, repo, number, reviewID) req, err := s.client.NewRequest("PUT", u, review) if err != nil { From cd5b665ed5b4d0885d0ba8488b34b0b2fb0c4afe Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Thu, 22 Dec 2016 00:24:51 +0100 Subject: [PATCH 12/22] Fix minor issue with comment for state --- github/pulls_reviews.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index db82b726465..4fbb8560350 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -20,7 +20,7 @@ type PullRequestReview struct { HTMLURL *string `json:"html_url,omitempty"` PullRequestURL *string `json:"pull_request_url,omitempty"` - // State can be "ACCEPTED", "DISMISSED", "CHANGES_REQUESTED" or "COMMENTED". + // State can be "ACCEPTED", "DISMISSED", "CHANGES_REQUESTED", "COMMENTED" or "PENDING". State *string `json:"state,omitempty"` } From 109ded2efaf5d78f6fc98d6dda6a046c93148703 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Fri, 23 Dec 2016 22:33:12 +0100 Subject: [PATCH 13/22] Add String methods and their tests for all new types --- github/pulls_reviews.go | 16 ++++++++++++++++ github/strings_test.go | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index 4fbb8560350..c025bf50a85 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -40,6 +40,10 @@ type PullRequestReviewComment struct { PullRequestURL *string `json:"pull_request_url,omitempty"` } +func (c PullRequestReviewComment) String() string { + return Stringify(c) +} + // DraftReviewComment represents a comment part of the review. type DraftReviewComment struct { Path *string `json:"path,omitempty"` @@ -47,6 +51,10 @@ type DraftReviewComment struct { Body *string `json:"body,omitempty"` } +func (c DraftReviewComment) String() string { + return Stringify(c) +} + // PullRequestReviewRequest represents a request to create a review. type PullRequestReviewRequest struct { Body *string `json:"body,omitempty"` @@ -54,11 +62,19 @@ type PullRequestReviewRequest struct { Comments []DraftReviewComment `json:"comments,omitempty"` } +func (r PullRequestReviewRequest) String() string { + return Stringify(r) +} + // PullRequestReviewDismissalRequest represents a request to dismiss a review. type PullRequestReviewDismissalRequest struct { Message *string `json:"message,omitempty"` } +func (r PullRequestReviewDismissalRequest) String() string { + return Stringify(r) +} + // ListReviews lists all reviews on the specified pull request. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request diff --git a/github/strings_test.go b/github/strings_test.go index a393eb6cfc5..9f14e3294cf 100644 --- a/github/strings_test.go +++ b/github/strings_test.go @@ -109,6 +109,11 @@ func TestString(t *testing.T) { {Organization{ID: Int(1)}, `github.Organization{ID:1}`}, {PullRequestComment{ID: Int(1)}, `github.PullRequestComment{ID:1}`}, {PullRequest{Number: Int(1)}, `github.PullRequest{Number:1}`}, + {PullRequestReview{ID: Int(1)}, `github.PullRequestReview{ID:1}`}, + {PullRequestReviewComment{ID: Int(1)}, `github.PullRequestReviewComment{ID:1}`}, + {DraftReviewComment{Position: Int(1)}, `github.DraftReviewComment{Position:1}`}, + {PullRequestReviewRequest{Body: String("r")}, `github.PullRequestReviewRequest{Body:"r"}`}, + {PullRequestReviewDismissalRequest{Message: String("r")}, `github.PullRequestReviewDismissalRequest{Message:"r"}`}, {PushEventCommit{SHA: String("s")}, `github.PushEventCommit{SHA:"s"}`}, {PushEvent{PushID: Int(1)}, `github.PushEvent{PushID:1}`}, {Reference{Ref: String("r")}, `github.Reference{Ref:"r"}`}, From 2bd08d4102fa3aa5cb5410978d78de1d2a2b9f64 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Fri, 23 Dec 2016 22:50:45 +0100 Subject: [PATCH 14/22] Add unit tests for invalid cases --- github/pulls_reviews_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index c1663a378ad..9e2b9ca2222 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -37,6 +37,11 @@ func TestPullRequestsService_ListReviews(t *testing.T) { } } +func TestPullRequestsService_ListReviews_invalidOwner(t *testing.T) { + _, _, err := client.PullRequests.ListReviews("%", "r", 1) + testURLParseError(t, err) +} + func TestPullRequestsService_GetReview(t *testing.T) { setup() defer teardown() @@ -58,6 +63,11 @@ func TestPullRequestsService_GetReview(t *testing.T) { } } +func TestPullRequestsService_GetReview_invalidOwner(t *testing.T) { + _, _, err := client.PullRequests.GetReview("%", "r", 1, 1) + testURLParseError(t, err) +} + func TestPullRequestsService_ListReviewComments(t *testing.T) { setup() defer teardown() From 87729c2e1c4576e586623a0233b530c310063f21 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Thu, 29 Dec 2016 02:06:18 +0100 Subject: [PATCH 15/22] Complete tests for invalid cases for all 6 new endpoints --- github/pulls_reviews_test.go | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index 9e2b9ca2222..575356284c7 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -92,6 +92,11 @@ func TestPullRequestsService_ListReviewComments(t *testing.T) { } } +func TestPullRequestsService_ListReviewComments_invalidOwner(t *testing.T) { + _, _, err := client.PullRequests.ListReviewComments("%", "r", 1, 1) + testURLParseError(t, err) +} + func TestPullRequestsService_CreateReview(t *testing.T) { setup() defer teardown() @@ -125,6 +130,11 @@ func TestPullRequestsService_CreateReview(t *testing.T) { } } +func TestPullRequestsService_CreateReview_invalidOwner(t *testing.T) { + _, _, err := client.PullRequests.CreateReview("%", "r", 1, &PullRequestReviewRequest{}) + testURLParseError(t, err) +} + func TestPullRequestsService_SubmitReview(t *testing.T) { setup() defer teardown() @@ -158,6 +168,11 @@ func TestPullRequestsService_SubmitReview(t *testing.T) { } } +func TestPullRequestsService_SubmitReview_invalidOwner(t *testing.T) { + _, _, err := client.PullRequests.SubmitReview("%", "r", 1, 1, &PullRequestReviewRequest{}) + testURLParseError(t, err) +} + func TestPullRequestsService_DismissReview(t *testing.T) { setup() defer teardown() @@ -187,3 +202,8 @@ func TestPullRequestsService_DismissReview(t *testing.T) { t.Errorf("PullRequests.DismissReview returned %+v, want %+v", review, want) } } + +func TestPullRequestsService_DismissReview_invalidOwner(t *testing.T) { + _, _, err := client.PullRequests.DismissReview("%", "r", 1, 1, &PullRequestReviewDismissalRequest{}) + testURLParseError(t, err) +} From a176b035298c0b603b8340b08414e5fd99185d42 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Thu, 29 Dec 2016 02:11:34 +0100 Subject: [PATCH 16/22] Replace PullRequestReviewComment with PullRequestComment - Change return type of ListReviewComments method to PullRequestComment. - Corresponding changes in unit tests. - Remove type PullRequestReviewComment. - Remove string test for PullRequestReviewComment. --- github/pulls_reviews.go | 20 ++------------------ github/pulls_reviews_test.go | 2 +- github/strings_test.go | 1 - 3 files changed, 3 insertions(+), 20 deletions(-) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index c025bf50a85..e5c6b1f3f26 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -28,22 +28,6 @@ func (p PullRequestReview) String() string { return Stringify(p) } -// PullRequestReviewComment represents a comment left on a pull request review. -type PullRequestReviewComment struct { - ID *int `json:"id,omitempty"` - User *User `json:"user,omitempty"` - Body *string `json:"body,omitempty"` - CreatedAt *time.Time `json:"created_at,omitempty"` - UpdatedAt *time.Time `json:"updated_at,omitempty"` - CommitID *string `json:"commit_id,omitempty"` - HTMLURL *string `json:"html_url,omitempty"` - PullRequestURL *string `json:"pull_request_url,omitempty"` -} - -func (c PullRequestReviewComment) String() string { - return Stringify(c) -} - // DraftReviewComment represents a comment part of the review. type DraftReviewComment struct { Path *string `json:"path,omitempty"` @@ -124,7 +108,7 @@ func (s *PullRequestsService) GetReview(owner string, repo string, number int, r // ListReviewComments lists all the comments for the specified review. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-reviews-comments -func (s *PullRequestsService) ListReviewComments(owner string, repo string, number int, reviewID int) ([]*PullRequestReviewComment, *Response, error) { +func (s *PullRequestsService) ListReviewComments(owner string, repo string, number int, reviewID int) ([]*PullRequestComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/comments", owner, repo, number, reviewID) req, err := s.client.NewRequest("GET", u, nil) @@ -135,7 +119,7 @@ func (s *PullRequestsService) ListReviewComments(owner string, repo string, numb // TODO: remove custom Accept header when this API fully launches req.Header.Set("Accept", mediaTypePullRequestReviewsPreview) - comments := new([]*PullRequestReviewComment) + comments := new([]*PullRequestComment) resp, err := s.client.Do(req, comments) if err != nil { return nil, resp, err diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index 575356284c7..6b42196e01b 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -83,7 +83,7 @@ func TestPullRequestsService_ListReviewComments(t *testing.T) { t.Errorf("PullRequests.ListReviewComments returned error: %v", err) } - want := []*PullRequestReviewComment{ + want := []*PullRequestComment{ {ID: Int(1)}, {ID: Int(2)}, } diff --git a/github/strings_test.go b/github/strings_test.go index 9f14e3294cf..a47f1eb6ea4 100644 --- a/github/strings_test.go +++ b/github/strings_test.go @@ -110,7 +110,6 @@ func TestString(t *testing.T) { {PullRequestComment{ID: Int(1)}, `github.PullRequestComment{ID:1}`}, {PullRequest{Number: Int(1)}, `github.PullRequest{Number:1}`}, {PullRequestReview{ID: Int(1)}, `github.PullRequestReview{ID:1}`}, - {PullRequestReviewComment{ID: Int(1)}, `github.PullRequestReviewComment{ID:1}`}, {DraftReviewComment{Position: Int(1)}, `github.DraftReviewComment{Position:1}`}, {PullRequestReviewRequest{Body: String("r")}, `github.PullRequestReviewRequest{Body:"r"}`}, {PullRequestReviewDismissalRequest{Message: String("r")}, `github.PullRequestReviewDismissalRequest{Message:"r"}`}, From e3b5e69c0d10b72ed30e350304d8764642835e3b Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Fri, 6 Jan 2017 00:25:41 +0100 Subject: [PATCH 17/22] Remove misleading comment from PullRequestReview --- github/pulls_reviews.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index e5c6b1f3f26..d257b4a1fea 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -19,9 +19,7 @@ type PullRequestReview struct { CommitID *string `json:"commit_id,omitempty"` HTMLURL *string `json:"html_url,omitempty"` PullRequestURL *string `json:"pull_request_url,omitempty"` - - // State can be "ACCEPTED", "DISMISSED", "CHANGES_REQUESTED", "COMMENTED" or "PENDING". - State *string `json:"state,omitempty"` + State *string `json:"state,omitempty"` } func (p PullRequestReview) String() string { From a1bf05566e407c485ffdaf6556dd18a492bfbc19 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Fri, 6 Jan 2017 02:54:43 +0100 Subject: [PATCH 18/22] Add a note and todo about known issue with SubmitReview --- github/pulls_reviews.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index d257b4a1fea..70785deab2e 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -151,6 +151,11 @@ func (s *PullRequestsService) CreateReview(owner string, repo string, number int // SubmitReview submits a specified review on the specified pull request. // +// Note: There is a known issue with this preview endpoint. +// Read more about it here - https://github.com/google/go-github/pull/497#discussion_r94593877 +// +// TODO: Remove this once we arrive at resolution with GitHub Support. +// // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#submit-a-pull-request-review func (s *PullRequestsService) SubmitReview(owner string, repo string, number int, reviewID int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/events", owner, repo, number, reviewID) From 91cc8ae84dc4fd9baea115e96e61201179f23dcd Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Tue, 31 Jan 2017 01:53:01 +0100 Subject: [PATCH 19/22] Add DeletePendingReview endpoint - Added new API endpoint for deleting a pending review. - Wrote unit tests for the same. --- github/pulls_reviews.go | 23 +++++++++++++++++++++++ github/pulls_reviews_test.go | 26 ++++++++++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index 70785deab2e..3db78c1a60f 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -103,6 +103,29 @@ func (s *PullRequestsService) GetReview(owner string, repo string, number int, r return review, resp, err } +// DeletePendingReview deletes the specified pull request pending review. +// +// GitHub API docs: https://developer.github.com/v3/pulls/reviews/#delete-a-pending-review +func (s *PullRequestsService) DeletePendingReview(owner string, repo string, number int, reviewID int) (*PullRequestReview, *Response, error) { + u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, reviewID) + + req, err := s.client.NewRequest("DELETE", u, nil) + if err != nil { + return nil, nil, err + } + + // TODO: remove custom Accept header when this API fully launches + req.Header.Set("Accept", mediaTypePullRequestReviewsPreview) + + review := new(PullRequestReview) + resp, err := s.client.Do(req, review) + if err != nil { + return nil, resp, err + } + + return review, resp, err +} + // ListReviewComments lists all the comments for the specified review. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-reviews-comments diff --git a/github/pulls_reviews_test.go b/github/pulls_reviews_test.go index 6b42196e01b..707fd5a6689 100644 --- a/github/pulls_reviews_test.go +++ b/github/pulls_reviews_test.go @@ -68,6 +68,32 @@ func TestPullRequestsService_GetReview_invalidOwner(t *testing.T) { testURLParseError(t, err) } +func TestPullRequestsService_DeletePendingReview(t *testing.T) { + setup() + defer teardown() + + mux.HandleFunc("/repos/o/r/pulls/1/reviews/1", func(w http.ResponseWriter, r *http.Request) { + testMethod(t, r, "DELETE") + testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview) + fmt.Fprint(w, `{"id":1}`) + }) + + review, _, err := client.PullRequests.DeletePendingReview("o", "r", 1, 1) + if err != nil { + t.Errorf("PullRequests.DeletePendingReview returned error: %v", err) + } + + want := &PullRequestReview{ID: Int(1)} + if !reflect.DeepEqual(review, want) { + t.Errorf("PullRequests.DeletePendingReview returned %+v, want %+v", review, want) + } +} + +func TestPullRequestsService_DeletePendingReview_invalidOwner(t *testing.T) { + _, _, err := client.PullRequests.DeletePendingReview("%", "r", 1, 1) + testURLParseError(t, err) +} + func TestPullRequestsService_ListReviewComments(t *testing.T) { setup() defer teardown() From bfda8ba502ca3f1cbe94c2eec8402a904e9013b5 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Thu, 2 Feb 2017 00:21:11 +0100 Subject: [PATCH 20/22] Make minor changes as suggested by gmlewis - Includes majorly the changes of return err to return nil when err is nil. --- github/pulls_reviews.go | 42 ++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index 3db78c1a60f..c450e3e2930 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -39,9 +39,9 @@ func (c DraftReviewComment) String() string { // PullRequestReviewRequest represents a request to create a review. type PullRequestReviewRequest struct { - Body *string `json:"body,omitempty"` - Event *string `json:"event,omitempty"` - Comments []DraftReviewComment `json:"comments,omitempty"` + Body *string `json:"body,omitempty"` + Event *string `json:"event,omitempty"` + Comments []*DraftReviewComment `json:"comments,omitempty"` } func (r PullRequestReviewRequest) String() string { @@ -60,7 +60,7 @@ func (r PullRequestReviewDismissalRequest) String() string { // ListReviews lists all reviews on the specified pull request. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request -func (s *PullRequestsService) ListReviews(owner string, repo string, number int) ([]*PullRequestReview, *Response, error) { +func (s *PullRequestsService) ListReviews(owner, repo string, number int) ([]*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews", owner, repo, number) req, err := s.client.NewRequest("GET", u, nil) @@ -71,19 +71,19 @@ func (s *PullRequestsService) ListReviews(owner string, repo string, number int) // TODO: remove custom Accept header when this API fully launches req.Header.Set("Accept", mediaTypePullRequestReviewsPreview) - reviews := new([]*PullRequestReview) - resp, err := s.client.Do(req, reviews) + var reviews []*PullRequestReview + resp, err := s.client.Do(req, &reviews) if err != nil { return nil, resp, err } - return *reviews, resp, err + return reviews, resp, nil } // GetReview fetches the specified pull request review. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-review -func (s *PullRequestsService) GetReview(owner string, repo string, number int, reviewID int) (*PullRequestReview, *Response, error) { +func (s *PullRequestsService) GetReview(owner, repo string, number, reviewID int) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, reviewID) req, err := s.client.NewRequest("GET", u, nil) @@ -100,13 +100,13 @@ func (s *PullRequestsService) GetReview(owner string, repo string, number int, r return nil, resp, err } - return review, resp, err + return review, resp, nil } // DeletePendingReview deletes the specified pull request pending review. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#delete-a-pending-review -func (s *PullRequestsService) DeletePendingReview(owner string, repo string, number int, reviewID int) (*PullRequestReview, *Response, error) { +func (s *PullRequestsService) DeletePendingReview(owner, repo string, number, reviewID int) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, reviewID) req, err := s.client.NewRequest("DELETE", u, nil) @@ -123,13 +123,13 @@ func (s *PullRequestsService) DeletePendingReview(owner string, repo string, num return nil, resp, err } - return review, resp, err + return review, resp, nil } // ListReviewComments lists all the comments for the specified review. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-reviews-comments -func (s *PullRequestsService) ListReviewComments(owner string, repo string, number int, reviewID int) ([]*PullRequestComment, *Response, error) { +func (s *PullRequestsService) ListReviewComments(owner, repo string, number, reviewID int) ([]*PullRequestComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/comments", owner, repo, number, reviewID) req, err := s.client.NewRequest("GET", u, nil) @@ -140,19 +140,19 @@ func (s *PullRequestsService) ListReviewComments(owner string, repo string, numb // TODO: remove custom Accept header when this API fully launches req.Header.Set("Accept", mediaTypePullRequestReviewsPreview) - comments := new([]*PullRequestComment) - resp, err := s.client.Do(req, comments) + var comments []*PullRequestComment + resp, err := s.client.Do(req, &comments) if err != nil { return nil, resp, err } - return *comments, resp, err + return comments, resp, nil } // CreateReview creates a new review on the specified pull request. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review -func (s *PullRequestsService) CreateReview(owner string, repo string, number int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { +func (s *PullRequestsService) CreateReview(owner, repo string, number int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews", owner, repo, number) req, err := s.client.NewRequest("POST", u, review) @@ -169,7 +169,7 @@ func (s *PullRequestsService) CreateReview(owner string, repo string, number int return nil, resp, err } - return r, resp, err + return r, resp, nil } // SubmitReview submits a specified review on the specified pull request. @@ -180,7 +180,7 @@ func (s *PullRequestsService) CreateReview(owner string, repo string, number int // TODO: Remove this once we arrive at resolution with GitHub Support. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#submit-a-pull-request-review -func (s *PullRequestsService) SubmitReview(owner string, repo string, number int, reviewID int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { +func (s *PullRequestsService) SubmitReview(owner, repo string, number, reviewID int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/events", owner, repo, number, reviewID) req, err := s.client.NewRequest("POST", u, review) @@ -197,13 +197,13 @@ func (s *PullRequestsService) SubmitReview(owner string, repo string, number int return nil, resp, err } - return r, resp, err + return r, resp, nil } // DismissReview dismisses a specified review on the specified pull request. // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#dismiss-a-pull-request-review -func (s *PullRequestsService) DismissReview(owner string, repo string, number int, reviewID int, review *PullRequestReviewDismissalRequest) (*PullRequestReview, *Response, error) { +func (s *PullRequestsService) DismissReview(owner, repo string, number, reviewID int, review *PullRequestReviewDismissalRequest) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/dismissals", owner, repo, number, reviewID) req, err := s.client.NewRequest("PUT", u, review) @@ -220,5 +220,5 @@ func (s *PullRequestsService) DismissReview(owner string, repo string, number in return nil, resp, err } - return r, resp, err + return r, resp, nil } From 36dbd69d38d6554586303a66f4e0e73c1254d870 Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Thu, 2 Feb 2017 01:11:09 +0100 Subject: [PATCH 21/22] Doc: Add comment about known error format issue --- github/pulls_reviews.go | 38 ++++++++++++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 4 deletions(-) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index c450e3e2930..3c3268aad0a 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -59,6 +59,11 @@ func (r PullRequestReviewDismissalRequest) String() string { // ListReviews lists all reviews on the specified pull request. // +// TODO: Follow up with GitHub support about an issue with this method's +// returned error format and remove this comment once it's fixed. +// Read mroe about it here - +// https://github.com/google/go-github/pull/497#issuecomment-267810912 +// // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request func (s *PullRequestsService) ListReviews(owner, repo string, number int) ([]*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews", owner, repo, number) @@ -82,6 +87,11 @@ func (s *PullRequestsService) ListReviews(owner, repo string, number int) ([]*Pu // GetReview fetches the specified pull request review. // +// TODO: Follow up with GitHub support about an issue with this method's +// returned error format and remove this comment once it's fixed. +// Read mroe about it here - +// https://github.com/google/go-github/pull/497#issuecomment-267810912 +// // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-review func (s *PullRequestsService) GetReview(owner, repo string, number, reviewID int) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, reviewID) @@ -105,6 +115,11 @@ func (s *PullRequestsService) GetReview(owner, repo string, number, reviewID int // DeletePendingReview deletes the specified pull request pending review. // +// TODO: Follow up with GitHub support about an issue with this method's +// returned error format and remove this comment once it's fixed. +// Read mroe about it here - +// https://github.com/google/go-github/pull/497#issuecomment-267810912 +// // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#delete-a-pending-review func (s *PullRequestsService) DeletePendingReview(owner, repo string, number, reviewID int) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d", owner, repo, number, reviewID) @@ -128,6 +143,11 @@ func (s *PullRequestsService) DeletePendingReview(owner, repo string, number, re // ListReviewComments lists all the comments for the specified review. // +// TODO: Follow up with GitHub support about an issue with this method's +// returned error format and remove this comment once it's fixed. +// Read mroe about it here - +// https://github.com/google/go-github/pull/497#issuecomment-267810912 +// // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-reviews-comments func (s *PullRequestsService) ListReviewComments(owner, repo string, number, reviewID int) ([]*PullRequestComment, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/comments", owner, repo, number, reviewID) @@ -151,6 +171,11 @@ func (s *PullRequestsService) ListReviewComments(owner, repo string, number, rev // CreateReview creates a new review on the specified pull request. // +// TODO: Follow up with GitHub support about an issue with this method's +// returned error format and remove this comment once it's fixed. +// Read mroe about it here - +// https://github.com/google/go-github/pull/497#issuecomment-267810912 +// // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review func (s *PullRequestsService) CreateReview(owner, repo string, number int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews", owner, repo, number) @@ -174,10 +199,10 @@ func (s *PullRequestsService) CreateReview(owner, repo string, number int, revie // SubmitReview submits a specified review on the specified pull request. // -// Note: There is a known issue with this preview endpoint. -// Read more about it here - https://github.com/google/go-github/pull/497#discussion_r94593877 -// -// TODO: Remove this once we arrive at resolution with GitHub Support. +// TODO: Follow up with GitHub support about an issue with this method's +// returned error format and remove this comment once it's fixed. +// Read mroe about it here - +// https://github.com/google/go-github/pull/497#issuecomment-267810912 // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#submit-a-pull-request-review func (s *PullRequestsService) SubmitReview(owner, repo string, number, reviewID int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { @@ -202,6 +227,11 @@ func (s *PullRequestsService) SubmitReview(owner, repo string, number, reviewID // DismissReview dismisses a specified review on the specified pull request. // +// TODO: Follow up with GitHub support about an issue with this method's +// returned error format and remove this comment once it's fixed. +// Read mroe about it here - +// https://github.com/google/go-github/pull/497#issuecomment-267810912 +// // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#dismiss-a-pull-request-review func (s *PullRequestsService) DismissReview(owner, repo string, number, reviewID int, review *PullRequestReviewDismissalRequest) (*PullRequestReview, *Response, error) { u := fmt.Sprintf("repos/%v/%v/pulls/%d/reviews/%d/dismissals", owner, repo, number, reviewID) From 0c0faa4599698ef7046187173316df2e843582ba Mon Sep 17 00:00:00 2001 From: Sahil Dua Date: Thu, 2 Feb 2017 22:02:25 +0100 Subject: [PATCH 22/22] Fix typo and mention issue link as comment --- github/pulls_reviews.go | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/github/pulls_reviews.go b/github/pulls_reviews.go index 3c3268aad0a..be57af88c72 100644 --- a/github/pulls_reviews.go +++ b/github/pulls_reviews.go @@ -61,8 +61,7 @@ func (r PullRequestReviewDismissalRequest) String() string { // // TODO: Follow up with GitHub support about an issue with this method's // returned error format and remove this comment once it's fixed. -// Read mroe about it here - -// https://github.com/google/go-github/pull/497#issuecomment-267810912 +// Read more about it here - https://github.com/google/go-github/issues/540 // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request func (s *PullRequestsService) ListReviews(owner, repo string, number int) ([]*PullRequestReview, *Response, error) { @@ -89,8 +88,7 @@ func (s *PullRequestsService) ListReviews(owner, repo string, number int) ([]*Pu // // TODO: Follow up with GitHub support about an issue with this method's // returned error format and remove this comment once it's fixed. -// Read mroe about it here - -// https://github.com/google/go-github/pull/497#issuecomment-267810912 +// Read more about it here - https://github.com/google/go-github/issues/540 // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-review func (s *PullRequestsService) GetReview(owner, repo string, number, reviewID int) (*PullRequestReview, *Response, error) { @@ -117,8 +115,7 @@ func (s *PullRequestsService) GetReview(owner, repo string, number, reviewID int // // TODO: Follow up with GitHub support about an issue with this method's // returned error format and remove this comment once it's fixed. -// Read mroe about it here - -// https://github.com/google/go-github/pull/497#issuecomment-267810912 +// Read more about it here - https://github.com/google/go-github/issues/540 // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#delete-a-pending-review func (s *PullRequestsService) DeletePendingReview(owner, repo string, number, reviewID int) (*PullRequestReview, *Response, error) { @@ -145,8 +142,7 @@ func (s *PullRequestsService) DeletePendingReview(owner, repo string, number, re // // TODO: Follow up with GitHub support about an issue with this method's // returned error format and remove this comment once it's fixed. -// Read mroe about it here - -// https://github.com/google/go-github/pull/497#issuecomment-267810912 +// Read more about it here - https://github.com/google/go-github/issues/540 // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#get-a-single-reviews-comments func (s *PullRequestsService) ListReviewComments(owner, repo string, number, reviewID int) ([]*PullRequestComment, *Response, error) { @@ -173,8 +169,7 @@ func (s *PullRequestsService) ListReviewComments(owner, repo string, number, rev // // TODO: Follow up with GitHub support about an issue with this method's // returned error format and remove this comment once it's fixed. -// Read mroe about it here - -// https://github.com/google/go-github/pull/497#issuecomment-267810912 +// Read more about it here - https://github.com/google/go-github/issues/540 // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#create-a-pull-request-review func (s *PullRequestsService) CreateReview(owner, repo string, number int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { @@ -201,8 +196,7 @@ func (s *PullRequestsService) CreateReview(owner, repo string, number int, revie // // TODO: Follow up with GitHub support about an issue with this method's // returned error format and remove this comment once it's fixed. -// Read mroe about it here - -// https://github.com/google/go-github/pull/497#issuecomment-267810912 +// Read more about it here - https://github.com/google/go-github/issues/540 // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#submit-a-pull-request-review func (s *PullRequestsService) SubmitReview(owner, repo string, number, reviewID int, review *PullRequestReviewRequest) (*PullRequestReview, *Response, error) { @@ -229,8 +223,7 @@ func (s *PullRequestsService) SubmitReview(owner, repo string, number, reviewID // // TODO: Follow up with GitHub support about an issue with this method's // returned error format and remove this comment once it's fixed. -// Read mroe about it here - -// https://github.com/google/go-github/pull/497#issuecomment-267810912 +// Read more about it here - https://github.com/google/go-github/issues/540 // // GitHub API docs: https://developer.github.com/v3/pulls/reviews/#dismiss-a-pull-request-review func (s *PullRequestsService) DismissReview(owner, repo string, number, reviewID int, review *PullRequestReviewDismissalRequest) (*PullRequestReview, *Response, error) {