Module: Octokit::Client::Reviews

Included in:
Octokit::Client
Defined in:
lib/octokit/client/reviews.rb

Overview

Methods for the Reviews API

Instance Method Summary collapse

Instance Method Details

#create_pull_request_review(repo, id, options = {}) ⇒ Sawyer::Resource

Create a pull request review

Examples:

comments = [
  { path: '.travis.yml', position: 10, body: 'ruby-head is under development that is not stable.' },
  { path: '.travis.yml', position: 32, body: 'ruby-head is also required in thervm section.' },
]
options = { event: 'REQUEST_CHANGES', comments: comments }
@client.create_pull_request_review('octokit/octokit.rb', 844, options)

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • id (Integer)

    The id of the pull request

  • options (Hash) (defaults to: {})

    Method options

  • comments (Hash)

    a customizable set of options

Options Hash (options):

  • :event (String)

    The review action (event) to perform; can be one of APPROVE, REQUEST_CHANGES, or COMMENT. If left blank, the review is left PENDING.

  • :body (String)

    The body text of the pull request review

  • :comments (Array<Hash>)

    Comments part of the review

Returns:

  • (Sawyer::Resource)

    ] Hash respresenting the review

See Also:



96
97
98
99
# File 'lib/octokit/client/reviews.rb', line 96

def create_pull_request_review(repo, id, options = {})
  options = ensure_api_media_type(:reviews, options)
  post "#{Repository.path repo}/pulls/#{id}/reviews", options
end

#delete_pull_request_review(repo, number, review, options = {}) ⇒ Sawyer::Resource

Delete a pending review

Examples:

@client.delete_pull_request_review('octokit/octokit.rb', 825, 6505518)

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    The id of the pull request

  • review (Integer)

    The id of the review

Returns:

  • (Sawyer::Resource)

    Hash representing the deleted review

See Also:



51
52
53
54
# File 'lib/octokit/client/reviews.rb', line 51

def delete_pull_request_review(repo, number, review, options = {})
  options = ensure_api_media_type(:reviews, options)
  delete "#{Repository.path repo}/pulls/#{number}/reviews/#{review}", options
end

#dismiss_pull_request_review(repo, number, review, message, options = {}) ⇒ Sawyer::Resource

Dismiss a pull request review

Examples:

@client.dismiss_pull_request_review('octokit/octokit.rb', 825, 6505518)

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    The id of the pull request

  • review (Integer)

    The id of the review

  • message (String)

    The message for the pull request review dismissal

Returns:

  • (Sawyer::Resource)

    Hash representing the dismissed review

See Also:



135
136
137
138
139
# File 'lib/octokit/client/reviews.rb', line 135

def dismiss_pull_request_review(repo, number, review, message, options = {})
  options = options.merge(message: message)
  options = ensure_api_media_type(:reviews, options)
  put "#{Repository.path repo}/pulls/#{number}/reviews/#{review}/dismissals", options
end

#pull_request_review(repo, number, review, options = {}) ⇒ Sawyer::Resource

Get a single review

Examples:

@client.pull_request_review('octokit/octokit.rb', 825, 6505518)

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    The id of the pull request

  • review (Integer)

    The id of the review

Returns:

  • (Sawyer::Resource)

    Hash representing the review

See Also:



35
36
37
38
# File 'lib/octokit/client/reviews.rb', line 35

def pull_request_review(repo, number, review, options = {})
  options = ensure_api_media_type(:reviews, options)
  get "#{Repository.path repo}/pulls/#{number}/reviews/#{review}", options
end

#pull_request_review_comments(repo, number, review, options = {}) ⇒ Array<Sawyer::Resource>

Get comments for a single review

Examples:

@client.pull_request_review_comments('octokit/octokit.rb', 825, 6505518)

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    The id of the pull request

  • review (Integer)

    The id of the review

Returns:

  • (Array<Sawyer::Resource>)

    Array of Hashes representing the review comments

See Also:



67
68
69
70
# File 'lib/octokit/client/reviews.rb', line 67

def pull_request_review_comments(repo, number, review, options = {})
  options = ensure_api_media_type(:reviews, options)
  get "#{Repository.path repo}/pulls/#{number}/reviews/#{review}/comments", options
end

#pull_request_review_requests(repo, id, options = {}) ⇒ Array<Sawyer::Resource>

List review requests

Examples:

@client.pull_request_review_requests('octokit/octokit.rb', 2)

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • id (Integer)

    The id of the pull request

Returns:

  • (Array<Sawyer::Resource>)

    Array of Hashes representing the review requests

See Also:



151
152
153
154
# File 'lib/octokit/client/reviews.rb', line 151

def pull_request_review_requests(repo, id, options = {})
  options = ensure_api_media_type(:reviews, options)
  get "#{Repository.path repo}/pulls/#{id}/requested_reviewers", options
end

#pull_request_reviews(repo, id, options = {}) ⇒ Array<Sawyer::Resource>

List reviews on a pull request

Examples:

@client.pull_request_reviews('octokit/octokit.rb', 2)

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • id (Integer)

    The id of the pull request

Returns:

  • (Array<Sawyer::Resource>)

    Array of Hashes representing the reviews

See Also:



19
20
21
22
# File 'lib/octokit/client/reviews.rb', line 19

def pull_request_reviews(repo, id, options = {})
  options = ensure_api_media_type(:reviews, options)
  get "#{Repository.path repo}/pulls/#{id}/reviews", options
end

#request_pull_request_review(repo, id, reviewers, options = {}) ⇒ Sawyer::Resource

Create a review request

Examples:

@client.request_pull_request_review('octokit/octokit.rb', 2, ['soudy'])

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • id (Integer)

    The id of the pull request

  • reviewers (Array<String>)

    An array of user logins that will be requested

Returns:

  • (Sawyer::Resource)

    ] Hash respresenting the pull request

See Also:



167
168
169
170
171
# File 'lib/octokit/client/reviews.rb', line 167

def request_pull_request_review(repo, id, reviewers, options = {})
  options = options.merge(reviewers: reviewers)
  options = ensure_api_media_type(:reviews, options)
  post "#{Repository.path repo}/pulls/#{id}/requested_reviewers", options
end

#submit_pull_request_review(repo, number, review, event, options = {}) ⇒ Sawyer::Resource

Submit a pull request review

Examples:

@client.submit_pull_request_review('octokit/octokit.rb', 825, 6505518,
                                   'APPROVE', body: 'LGTM!')

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    The id of the pull request

  • review (Integer)

    The id of the review

  • event (String)

    The review action (event) to perform; can be one of APPROVE, REQUEST_CHANGES, or COMMENT.

  • options (Hash) (defaults to: {})

    Method options

Options Hash (options):

  • :body (String)

    The body text of the pull request review

Returns:

  • (Sawyer::Resource)

    Hash respresenting the review

See Also:



117
118
119
120
121
# File 'lib/octokit/client/reviews.rb', line 117

def submit_pull_request_review(repo, number, review, event, options = {})
  options = options.merge(event: event)
  options = ensure_api_media_type(:reviews, options)
  post "#{Repository.path repo}/pulls/#{number}/reviews/#{review}/events", options
end