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:



92
93
94
# File 'lib/octokit/client/reviews.rb', line 92

def create_pull_request_review(repo, id, 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:



49
50
51
# File 'lib/octokit/client/reviews.rb', line 49

def delete_pull_request_review(repo, number, review, 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, 'The message.')

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:



129
130
131
132
# File 'lib/octokit/client/reviews.rb', line 129

def dismiss_pull_request_review(repo, number, review, message, options = {})
  options = options.merge(message: message)
  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:



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

def pull_request_review(repo, number, review, 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:



64
65
66
# File 'lib/octokit/client/reviews.rb', line 64

def pull_request_review_comments(repo, number, review, options = {})
  paginate "#{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:



144
145
146
# File 'lib/octokit/client/reviews.rb', line 144

def pull_request_review_requests(repo, id, options = {})
  paginate "#{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
# File 'lib/octokit/client/reviews.rb', line 19

def pull_request_reviews(repo, id, options = {})
  paginate "#{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:



159
160
161
162
# File 'lib/octokit/client/reviews.rb', line 159

def request_pull_request_review(repo, id, reviewers, options = {})
  options = options.merge(reviewers: reviewers)
  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:



112
113
114
115
# File 'lib/octokit/client/reviews.rb', line 112

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