Skip to content

Commit

Permalink
Merge pull request #1047 from octokit/rework-request-review
Browse files Browse the repository at this point in the history
Rework request review
  • Loading branch information
Katrina Owen authored Aug 7, 2018
2 parents da4c051 + 23ea660 commit b57d51b
Show file tree
Hide file tree
Showing 18 changed files with 139 additions and 39 deletions.
44 changes: 33 additions & 11 deletions lib/octokit/client/reviews.rb
Original file line number Diff line number Diff line change
Expand Up @@ -149,37 +149,59 @@ def pull_request_review_requests(repo, number, options = {})
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
# @param number [Integer] Number ID of the pull request
# @param reviewers [Array<String>] An array of user logins that will be requested
# @param options [Hash] :reviewers [Array<String>] An array of user logins
# @param options [Hash] :team_reviewers [Array<String>] An array of team slugs
# @see https://developer.github.com/v3/pulls/review_requests/#create-a-review-request
#
# @example
# @client.request_pull_request_review('octokit/octokit.rb', 2, ['soudy'])
# @client.request_pull_request_review('octokit/octokit.rb', 2, reviewers: ['soudy'])
#
# @return [Sawyer::Resource>] Hash respresenting the pull request
def request_pull_request_review(repo, number, reviewers, options = {})
options = options.merge(reviewers: reviewers)
def request_pull_request_review(repo, number, reviewers = {}, options = {})
# TODO(5.0): remove deprecated behavior
if reviewers.is_a?(Array)
octokit_warn(
"Deprecated: Octokit::Client#request_pull_request_review "\
"no longer takes a separate :reviewers argument.\n" \
"Please update your call to pass :reviewers and :team_reviewers as part of the options hash."
)
options = options.merge(reviewers: reviewers)
else
options = options.merge(reviewers)
end

post "#{Repository.path repo}/pulls/#{number}/requested_reviewers", options
end

# Delete a review request
#
# @param repo [Integer, String, Hash, Repository] A GitHub repository
# @param id [Integer] The id of the pull request
# @param reviewers [Hash] A hash including "reviewers" which is an array of user
# logins and "team_reviewers" which is an array of team slug
# @param options [Hash] :reviewers [Array] An array of user logins
# @param options [Hash] :team_reviewers [Array] An array of team slugs
#
# @see https://developer.github.com/v3/pulls/review_requests/#delete-a-review-request
#
# @example
# reviewers = {
# options = {
# "reviewers" => [ "octocat", "hubot", "other_user" ],
# "team_reviewers" => [ "justice-league" ]
# }
# @client.delete_request_pull_request_review('octokit/octokit.rb', 2, reviewers)
# @client.delete_pull_request_review_request('octokit/octokit.rb', 2, options)
#
# @return [Sawyer::Resource>] Hash representing the pull request
def delete_pull_request_review_request(repo, id, reviewers, options = {})
# "reviewers" has to be an array otherwise "422 - Invalid request"
options = options.merge(reviewers: reviewers.values.flatten)
def delete_pull_request_review_request(repo, id, reviewers={}, options = {})
# TODO(5.0): remove deprecated behavior
if !reviewers.empty? && !options.empty?
octokit_warn(
"Deprecated: Octokit::Client#delete_pull_request_review_request "\
"no longer takes a separate :reviewers argument.\n" \
"Please update your call to pass :reviewers and :team_reviewers as part of the options hash."
)
end
# For backwards compatibility, this endpoint can be called with a separate reviewers hash.
# If not called with a separate hash, then 'reviewers' is, in fact, 'options'.
options = options.merge(reviewers)
delete "#{Repository.path repo}/pulls/#{id}/requested_reviewers", options
end
end
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"http_interactions":[{"request":{"method":"get","uri":"https://api.github.com/repos/octokit/octokit.rb/pulls/825/reviews/6505518","body":{"encoding":"US-ASCII","base64_string":""},"headers":{"Accept":["application/vnd.github.v3+json"],"User-Agent":["Octokit Ruby Gem 4.9.0"],"Content-Type":["application/json"],"Authorization":["token <<ACCESS_TOKEN>>"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Date":["Wed, 06 Jun 2018 21:38:13 GMT"],"Content-Type":["application/json; charset=utf-8"],"Transfer-Encoding":["chunked"],"Server":["GitHub.com"],"Status":["200 OK"],"X-Ratelimit-Limit":["5000"],"X-Ratelimit-Remaining":["4838"],"X-Ratelimit-Reset":["1528322739"],"Cache-Control":["private, max-age=60, s-maxage=60"],"Vary":["Accept, Authorization, Cookie, X-GitHub-OTP","Accept-Encoding"],"Etag":["W/\"55a01215e2e381d19700df19b809e5cf\""],"X-Oauth-Scopes":["admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion"],"X-Accepted-Oauth-Scopes":[""],"X-Github-Media-Type":["github.v3; format=json"],"Access-Control-Expose-Headers":["ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval"],"Access-Control-Allow-Origin":["*"],"Strict-Transport-Security":["max-age=31536000; includeSubdomains; preload"],"X-Frame-Options":["deny"],"X-Content-Type-Options":["nosniff"],"X-Xss-Protection":["1; mode=block"],"Referrer-Policy":["origin-when-cross-origin, strict-origin-when-cross-origin"],"Content-Security-Policy":["default-src 'none'"],"X-Runtime-Rack":["0.125355"],"X-Github-Request-Id":["C8FC:7AC2:96A022:AC80E8:5B185445"]},"body":{"encoding":"ASCII-8BIT","base64_string":"eyJpZCI6NjUwNTUxOCwibm9kZV9pZCI6Ik1ERTNPbEIxYkd4U1pYRjFaWE4w\nVW1WMmFXVjNOalV3TlRVeE9BPT0iLCJ1c2VyIjp7ImxvZ2luIjoidGFyZWJ5\ndGUiLCJpZCI6NTY0MTEzLCJub2RlX2lkIjoiTURRNlZYTmxjalUyTkRFeE13\nPT0iLCJhdmF0YXJfdXJsIjoiaHR0cHM6Ly9hdmF0YXJzMi5naXRodWJ1c2Vy\nY29udGVudC5jb20vdS81NjQxMTM/dj00IiwiZ3JhdmF0YXJfaWQiOiIiLCJ1\ncmwiOiJodHRwczovL2FwaS5naXRodWIuY29tL3VzZXJzL3RhcmVieXRlIiwi\naHRtbF91cmwiOiJodHRwczovL2dpdGh1Yi5jb20vdGFyZWJ5dGUiLCJmb2xs\nb3dlcnNfdXJsIjoiaHR0cHM6Ly9hcGkuZ2l0aHViLmNvbS91c2Vycy90YXJl\nYnl0ZS9mb2xsb3dlcnMiLCJmb2xsb3dpbmdfdXJsIjoiaHR0cHM6Ly9hcGku\nZ2l0aHViLmNvbS91c2Vycy90YXJl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ik1FTUJFUiIsIl9saW5r\ncyI6eyJodG1sIjp7ImhyZWYiOiJodHRwczovL2dpdGh1Yi5jb20vb2N0b2tp\ndC9vY3Rva2l0LnJiL3B1bGwvODI1I3B1bGxyZXF1ZXN0cmV2aWV3LTY1MDU1\nMTgifSwicHVsbF9yZXF1ZXN0Ijp7ImhyZWYiOiJodHRwczovL2FwaS5naXRo\ndWIuY29tL3JlcG9zL29jdG9raXQvb2N0b2tpdC5yYi9wdWxscy84MjUifX0s\nInN1Ym1pdHRlZF9hdCI6IjIwMTYtMTAtMzFUMTk6MTQ6MDJaIiwiY29tbWl0\nX2lkIjoiMWI3NDFjOGNmZDdiNTQwMjY3OGFkM2IyNTQzM2ZlOGIyOTI3YmUw\nNCJ9\n"},"http_version":null},"recorded_at":"Wed, 06 Jun 2018 21:38:13 GMT"}],"recorded_with":"VCR 3.0.3"}
{"http_interactions":[{"request":{"method":"get","uri":"https://api.github.com/repos/octokit/octokit.rb/pulls/825/reviews/6505518","body":{"encoding":"US-ASCII","base64_string":""},"headers":{"Accept":["application/vnd.github.v3+json"],"User-Agent":["Octokit Ruby Gem 4.9.0"],"Content-Type":["application/json"],"Authorization":["token <<ACCESS_TOKEN>>"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Server":["GitHub.com"],"Date":["Tue, 07 Aug 2018 15:08:20 GMT"],"Content-Type":["application/json; charset=utf-8"],"Transfer-Encoding":["chunked"],"Status":["200 OK"],"X-Ratelimit-Limit":["5000"],"X-Ratelimit-Remaining":["4882"],"X-Ratelimit-Reset":["1533657311"],"Cache-Control":["private, max-age=60, s-maxage=60"],"Vary":["Accept, Authorization, Cookie, X-GitHub-OTP"],"Etag":["W/\"dee43dabab8f3849da2886edc330e859\""],"X-Oauth-Scopes":["admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user"],"X-Accepted-Oauth-Scopes":[""],"X-Github-Media-Type":["github.v3; format=json"],"Access-Control-Expose-Headers":["ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval"],"Access-Control-Allow-Origin":["*"],"Strict-Transport-Security":["max-age=31536000; includeSubdomains; preload"],"X-Frame-Options":["deny"],"X-Content-Type-Options":["nosniff"],"X-Xss-Protection":["1; mode=block"],"Referrer-Policy":["origin-when-cross-origin, strict-origin-when-cross-origin"],"Content-Security-Policy":["default-src 'none'"],"X-Runtime-Rack":["0.147006"],"X-Github-Request-Id":["EC88:202C:26308DB:4690D54:5B69B5E4"]},"body":{"encoding":"ASCII-8BIT","base64_string":"eyJpZCI6NjUwNTUxOCwibm9kZV9pZCI6Ik1ERTNPbEIxYkd4U1pYRjFaWE4w\nVW1WMmFXVjNOalV3TlRVeE9BPT0iLCJ1c2VyIjp7ImxvZ2luIjoiPEdJVEhV\nQl9MT0dJTj4iLCJpZCI6NTY0MTEzLCJub2RlX2lkIjoiTURRNlZYTmxjalUy\nTkRFeE13PT0iLCJhdmF0YXJfdXJsIjoiaHR0cHM6Ly9hdmF0YXJzMi5naXRo\ndWJ1c2VyY29udGVudC5jb20vdS81NjQxMTM/dj00IiwiZ3JhdmF0YXJfaWQi\nOiIiLCJ1cmwiOiJodHRwczovL2FwaS5naXRodWIuY29tL3VzZXJzLzxHSVRI\nVUJfTE9HSU4+IiwiaHRtbF91cmwiOiJodHRwczovL2dpdGh1Yi5jb20vPEdJ\nVEhVQl9MT0dJTj4iLCJmb2xsb3dlcnNfdXJsIjoiaHR0cHM6Ly9hcGkuZ2l0\naHViLmNvbS91c2Vycy88R0lUSFVCX0xPR0lOPi9mb2xsb3dlcnMiLCJmb2xs\nb3dpbmdfdXJsIjoiaHR0cHM6Ly9hcGkuZ2l0aHViLmNvbS91c2Vycy88R0lU\nSFVCX0xPR0lOPi9mb2xsb3dpbmd7L290aGVyX3VzZXJ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c3NvY2lhdGlvbiI6Ik1FTUJFUiIsIl9saW5rcyI6eyJodG1sIjp7ImhyZWYi\nOiJodHRwczovL2dpdGh1Yi5jb20vb2N0b2tpdC9vY3Rva2l0LnJiL3B1bGwv\nODI1I3B1bGxyZXF1ZXN0cmV2aWV3LTY1MDU1MTgifSwicHVsbF9yZXF1ZXN0\nIjp7ImhyZWYiOiJodHRwczovL2FwaS5naXRodWIuY29tL3JlcG9zL29jdG9r\naXQvb2N0b2tpdC5yYi9wdWxscy84MjUifX0sInN1Ym1pdHRlZF9hdCI6IjIw\nMTYtMTAtMzFUMTk6MTQ6MDJaIiwiY29tbWl0X2lkIjoiMWI3NDFjOGNmZDdi\nNTQwMjY3OGFkM2IyNTQzM2ZlOGIyOTI3YmUwNCJ9\n"},"http_version":null},"recorded_at":"Tue, 07 Aug 2018 15:08:20 GMT"}],"recorded_with":"VCR 3.0.3"}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"http_interactions":[{"request":{"method":"get","uri":"https://api.github.com/repos/octokit/octokit.rb/pulls/825/reviews/6505518/comments","body":{"encoding":"US-ASCII","base64_string":""},"headers":{"Accept":["application/vnd.github.v3+json"],"User-Agent":["Octokit Ruby Gem 4.9.0"],"Content-Type":["application/json"],"Authorization":["token <<ACCESS_TOKEN>>"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Date":["Wed, 06 Jun 2018 21:<GITHUB_TEST_INTEGRATION_INSTALLATION>:38 GMT"],"Content-Type":["application/json; charset=utf-8"],"Content-Length":["2"],"Server":["GitHub.com"],"Status":["200 OK"],"X-Ratelimit-Limit":["5000"],"X-Ratelimit-Remaining":["4887"],"X-Ratelimit-Reset":["1528322739"],"Cache-Control":["private, max-age=60, s-maxage=60"],"Vary":["Accept, Authorization, Cookie, X-GitHub-OTP","Accept-Encoding"],"Etag":["\"8f4a8adc80dcd5a50c93ab0d3c152c7c\""],"X-Oauth-Scopes":["admin:gpg_key, admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user, write:discussion"],"X-Accepted-Oauth-Scopes":[""],"X-Github-Media-Type":["github.v3; format=json"],"Access-Control-Expose-Headers":["ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval"],"Access-Control-Allow-Origin":["*"],"Strict-Transport-Security":["max-age=31536000; includeSubdomains; preload"],"X-Frame-Options":["deny"],"X-Content-Type-Options":["nosniff"],"X-Xss-Protection":["1; mode=block"],"Referrer-Policy":["origin-when-cross-origin, strict-origin-when-cross-origin"],"Content-Security-Policy":["default-src 'none'"],"X-Runtime-Rack":["0.082699"],"X-Github-Request-Id":["C8C5:7AC4:1202ECD:14DBFFC:5B185<GITHUB_TEST_INTEGRATION>2"]},"body":{"encoding":"UTF-8","base64_string":"W10=\n"},"http_version":null},"recorded_at":"Wed, 06 Jun 2018 21:37:38 GMT"}],"recorded_with":"VCR 3.0.3"}
{"http_interactions":[{"request":{"method":"get","uri":"https://api.github.com/repos/octokit/octokit.rb/pulls/825/reviews/6505518/comments","body":{"encoding":"US-ASCII","base64_string":""},"headers":{"Accept":["application/vnd.github.v3+json"],"User-Agent":["Octokit Ruby Gem 4.9.0"],"Content-Type":["application/json"],"Authorization":["token <<ACCESS_TOKEN>>"],"Accept-Encoding":["gzip;q=1.0,deflate;q=0.6,identity;q=0.3"]}},"response":{"status":{"code":200,"message":"OK"},"headers":{"Server":["GitHub.com"],"Date":["Tue, 07 Aug 2018 15:08:20 GMT"],"Content-Type":["application/json; charset=utf-8"],"Content-Length":["2"],"Status":["200 OK"],"X-Ratelimit-Limit":["5000"],"X-Ratelimit-Remaining":["4883"],"X-Ratelimit-Reset":["1533657311"],"Cache-Control":["private, max-age=60, s-maxage=60"],"Vary":["Accept, Authorization, Cookie, X-GitHub-OTP"],"Etag":["\"34eb689bdcfe4f33014e7ef8facada5e\""],"X-Oauth-Scopes":["admin:org, admin:org_hook, admin:public_key, admin:repo_hook, delete_repo, gist, notifications, repo, user"],"X-Accepted-Oauth-Scopes":[""],"X-Github-Media-Type":["github.v3; format=json"],"Access-Control-Expose-Headers":["ETag, Link, Retry-After, X-GitHub-OTP, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, X-OAuth-Scopes, X-Accepted-OAuth-Scopes, X-Poll-Interval"],"Access-Control-Allow-Origin":["*"],"Strict-Transport-Security":["max-age=31536000; includeSubdomains; preload"],"X-Frame-Options":["deny"],"X-Content-Type-Options":["nosniff"],"X-Xss-Protection":["1; mode=block"],"Referrer-Policy":["origin-when-cross-origin, strict-origin-when-cross-origin"],"Content-Security-Policy":["default-src 'none'"],"X-Runtime-Rack":["0.144084"],"X-Github-Request-Id":["EC87:202B:F2B948:235597C:5B69B5E4"]},"body":{"encoding":"UTF-8","base64_string":"W10=\n"},"http_version":null},"recorded_at":"Tue, 07 Aug 2018 15:08:20 GMT"}],"recorded_with":"VCR 3.0.3"}
Loading

0 comments on commit b57d51b

Please sign in to comment.