Skip to content

Commit 1151660

Browse files
varadarajanadmitshur
authored andcommitted
Remove custom media type for Pull Request Reviews API. (#641)
The Pull Request Reviews API (include Review Requests) has become an official part of GitHub API v3, so the preview API media type is no longer needed. See announcement at https://developer.github.com/changes/2017-05-09-end-black-cat-preview/. Resolves #638.
1 parent 4a42a1d commit 1151660

File tree

5 files changed

+0
-45
lines changed

5 files changed

+0
-45
lines changed

github/github.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,9 +92,6 @@ const (
9292
// https://developer.github.com/changes/2017-01-05-commit-search-api/
9393
mediaTypeCommitSearchPreview = "application/vnd.github.cloak-preview+json"
9494

95-
// https://developer.github.com/changes/2016-12-14-reviews-api/
96-
mediaTypePullRequestReviewsPreview = "application/vnd.github.black-cat-preview+json"
97-
9895
// https://developer.github.com/changes/2017-02-28-user-blocking-apis-and-webhook/
9996
mediaTypeBlockUsersPreview = "application/vnd.github.giant-sentry-fist-preview+json"
10097
)

github/pulls_reviewers.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,6 @@ func (s *PullRequestsService) RequestReviewers(ctx context.Context, owner, repo
2626
return nil, nil, err
2727
}
2828

29-
// TODO: remove custom Accept header when this API fully launches
30-
req.Header.Set("Accept", mediaTypePullRequestReviewsPreview)
31-
3229
r := new(PullRequest)
3330
resp, err := s.client.Do(ctx, req, r)
3431
if err != nil {
@@ -53,9 +50,6 @@ func (s *PullRequestsService) ListReviewers(ctx context.Context, owner, repo str
5350
return nil, nil, err
5451
}
5552

56-
// TODO: remove custom Accept header when this API fully launches
57-
req.Header.Set("Accept", mediaTypePullRequestReviewsPreview)
58-
5953
var users []*User
6054
resp, err := s.client.Do(ctx, req, &users)
6155
if err != nil {
@@ -81,8 +75,5 @@ func (s *PullRequestsService) RemoveReviewers(ctx context.Context, owner, repo s
8175
return nil, err
8276
}
8377

84-
// TODO: remove custom Accept header when this API fully launches
85-
req.Header.Set("Accept", mediaTypePullRequestReviewsPreview)
86-
8778
return s.client.Do(ctx, req, reviewers)
8879
}

github/pulls_reviewers_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ func TestRequestReviewers(t *testing.T) {
1919

2020
mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) {
2121
testMethod(t, r, "POST")
22-
testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview)
2322
testBody(t, r, `{"reviewers":["octocat","googlebot"]}`+"\n")
2423
fmt.Fprint(w, `{"number":1}`)
2524
})
@@ -41,7 +40,6 @@ func TestRemoveReviewers(t *testing.T) {
4140

4241
mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) {
4342
testMethod(t, r, "DELETE")
44-
testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview)
4543
testBody(t, r, `{"reviewers":["octocat","googlebot"]}`+"\n")
4644
})
4745

@@ -57,7 +55,6 @@ func TestListReviewers(t *testing.T) {
5755

5856
mux.HandleFunc("/repos/o/r/pulls/1/requested_reviewers", func(w http.ResponseWriter, r *http.Request) {
5957
testMethod(t, r, "GET")
60-
testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview)
6158
fmt.Fprint(w, `[{"login":"octocat","id":1}]`)
6259
})
6360

@@ -86,7 +83,6 @@ func TestListReviewers_withOptions(t *testing.T) {
8683
testFormValues(t, r, values{
8784
"page": "2",
8885
})
89-
testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview)
9086
fmt.Fprint(w, `[]`)
9187
})
9288

github/pulls_reviews.go

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,6 @@ func (s *PullRequestsService) ListReviews(ctx context.Context, owner, repo strin
7777
return nil, nil, err
7878
}
7979

80-
// TODO: remove custom Accept header when this API fully launches
81-
req.Header.Set("Accept", mediaTypePullRequestReviewsPreview)
82-
8380
var reviews []*PullRequestReview
8481
resp, err := s.client.Do(ctx, req, &reviews)
8582
if err != nil {
@@ -104,9 +101,6 @@ func (s *PullRequestsService) GetReview(ctx context.Context, owner, repo string,
104101
return nil, nil, err
105102
}
106103

107-
// TODO: remove custom Accept header when this API fully launches
108-
req.Header.Set("Accept", mediaTypePullRequestReviewsPreview)
109-
110104
review := new(PullRequestReview)
111105
resp, err := s.client.Do(ctx, req, review)
112106
if err != nil {
@@ -131,9 +125,6 @@ func (s *PullRequestsService) DeletePendingReview(ctx context.Context, owner, re
131125
return nil, nil, err
132126
}
133127

134-
// TODO: remove custom Accept header when this API fully launches
135-
req.Header.Set("Accept", mediaTypePullRequestReviewsPreview)
136-
137128
review := new(PullRequestReview)
138129
resp, err := s.client.Do(ctx, req, review)
139130
if err != nil {
@@ -162,9 +153,6 @@ func (s *PullRequestsService) ListReviewComments(ctx context.Context, owner, rep
162153
return nil, nil, err
163154
}
164155

165-
// TODO: remove custom Accept header when this API fully launches
166-
req.Header.Set("Accept", mediaTypePullRequestReviewsPreview)
167-
168156
var comments []*PullRequestComment
169157
resp, err := s.client.Do(ctx, req, &comments)
170158
if err != nil {
@@ -189,9 +177,6 @@ func (s *PullRequestsService) CreateReview(ctx context.Context, owner, repo stri
189177
return nil, nil, err
190178
}
191179

192-
// TODO: remove custom Accept header when this API fully launches
193-
req.Header.Set("Accept", mediaTypePullRequestReviewsPreview)
194-
195180
r := new(PullRequestReview)
196181
resp, err := s.client.Do(ctx, req, r)
197182
if err != nil {
@@ -216,9 +201,6 @@ func (s *PullRequestsService) SubmitReview(ctx context.Context, owner, repo stri
216201
return nil, nil, err
217202
}
218203

219-
// TODO: remove custom Accept header when this API fully launches
220-
req.Header.Set("Accept", mediaTypePullRequestReviewsPreview)
221-
222204
r := new(PullRequestReview)
223205
resp, err := s.client.Do(ctx, req, r)
224206
if err != nil {
@@ -243,9 +225,6 @@ func (s *PullRequestsService) DismissReview(ctx context.Context, owner, repo str
243225
return nil, nil, err
244226
}
245227

246-
// TODO: remove custom Accept header when this API fully launches
247-
req.Header.Set("Accept", mediaTypePullRequestReviewsPreview)
248-
249228
r := new(PullRequestReview)
250229
resp, err := s.client.Do(ctx, req, r)
251230
if err != nil {

github/pulls_reviews_test.go

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ func TestPullRequestsService_ListReviews(t *testing.T) {
2323
testFormValues(t, r, values{
2424
"page": "2",
2525
})
26-
testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview)
2726
fmt.Fprint(w, `[{"id":1},{"id":2}]`)
2827
})
2928

@@ -53,7 +52,6 @@ func TestPullRequestsService_GetReview(t *testing.T) {
5352

5453
mux.HandleFunc("/repos/o/r/pulls/1/reviews/1", func(w http.ResponseWriter, r *http.Request) {
5554
testMethod(t, r, "GET")
56-
testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview)
5755
fmt.Fprint(w, `{"id":1}`)
5856
})
5957

@@ -79,7 +77,6 @@ func TestPullRequestsService_DeletePendingReview(t *testing.T) {
7977

8078
mux.HandleFunc("/repos/o/r/pulls/1/reviews/1", func(w http.ResponseWriter, r *http.Request) {
8179
testMethod(t, r, "DELETE")
82-
testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview)
8380
fmt.Fprint(w, `{"id":1}`)
8481
})
8582

@@ -105,7 +102,6 @@ func TestPullRequestsService_ListReviewComments(t *testing.T) {
105102

106103
mux.HandleFunc("/repos/o/r/pulls/1/reviews/1/comments", func(w http.ResponseWriter, r *http.Request) {
107104
testMethod(t, r, "GET")
108-
testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview)
109105
fmt.Fprint(w, `[{"id":1},{"id":2}]`)
110106
})
111107

@@ -132,7 +128,6 @@ func TestPullRequestsService_ListReviewComments_withOptions(t *testing.T) {
132128
testFormValues(t, r, values{
133129
"page": "2",
134130
})
135-
testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview)
136131
fmt.Fprint(w, `[]`)
137132
})
138133

@@ -161,7 +156,6 @@ func TestPullRequestsService_CreateReview(t *testing.T) {
161156
json.NewDecoder(r.Body).Decode(v)
162157

163158
testMethod(t, r, "POST")
164-
testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview)
165159
if !reflect.DeepEqual(v, input) {
166160
t.Errorf("Request body = %+v, want %+v", v, input)
167161
}
@@ -199,7 +193,6 @@ func TestPullRequestsService_SubmitReview(t *testing.T) {
199193
json.NewDecoder(r.Body).Decode(v)
200194

201195
testMethod(t, r, "POST")
202-
testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview)
203196
if !reflect.DeepEqual(v, input) {
204197
t.Errorf("Request body = %+v, want %+v", v, input)
205198
}
@@ -234,7 +227,6 @@ func TestPullRequestsService_DismissReview(t *testing.T) {
234227
json.NewDecoder(r.Body).Decode(v)
235228

236229
testMethod(t, r, "PUT")
237-
testHeader(t, r, "Accept", mediaTypePullRequestReviewsPreview)
238230
if !reflect.DeepEqual(v, input) {
239231
t.Errorf("Request body = %+v, want %+v", v, input)
240232
}

0 commit comments

Comments
 (0)