123456789_123456789_123456789_123456789_123456789_

Module: Octokit::Client::Reviews

Relationships & Source Files
Extension / Inclusion / Inheritance Descendants
Included In:
Defined in: lib/octokit/client/reviews.rb

Overview

Methods for the Reviews API

Instance Method Summary

Instance Method Details

#create_pull_request_review(repo, number, 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

  • number (Integer)

    Number 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:

[ GitHub ]

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

def create_pull_request_review(repo, number, options = {})
  post "#{Repository.path repo}/pulls/#{number}/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)

    Number ID of the pull request

  • review (Integer)

    The id of the review

Returns:

  • (Sawyer::Resource)

    Hash representing the deleted review

See Also:

[ GitHub ]

  
# 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

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

Delete a review request

Examples:

options = {
  "reviewers" => [ "octocat", "hubot", "other_user" ],
  "team_reviewers" => [ "justice-league" ]
}
@client.delete_pull_request_review_request('octokit/octokit.rb', 2, options)

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • id (Integer)

    The id of the pull request

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

    :reviewers [Array] An array of user logins

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

    :team_reviewers [Array] An array of team slugs

Returns:

  • (Sawyer::Resource)

    ] Hash representing the pull request

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/reviews.rb', line 193

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

#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)

    Number 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:

[ GitHub ]

  
# 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)

    Number ID of the pull request

  • review (Integer)

    The id of the review

Returns:

  • (Sawyer::Resource)

    Hash representing the review

See Also:

[ GitHub ]

  
# 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)

    Number 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:

[ GitHub ]

  
# 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, number, 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

  • number (Integer)

    Number ID of the pull request

Returns:

  • (Array<Sawyer::Resource>)

    Array of Hashes representing the review requests

See Also:

[ GitHub ]

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

def pull_request_review_requests(repo, number, options = {})
  paginate "#{Repository.path repo}/pulls/#{number}/requested_reviewers", options
end

#pull_request_reviews(repo, number, 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

  • number (Integer)

    Number ID of the pull request

Returns:

  • (Array<Sawyer::Resource>)

    Array of Hashes representing the reviews

See Also:

[ GitHub ]

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

def pull_request_reviews(repo, number, options = {})
  paginate "#{Repository.path repo}/pulls/#{number}/reviews", options
end

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

Create a review request

Examples:

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

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    Number ID of the pull request

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

    :reviewers [Array] An array of user logins

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

    :team_reviewers [Array] An array of team slugs

Returns:

  • (Sawyer::Resource)

    ] Hash respresenting the pull request

See Also:

[ GitHub ]

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

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

#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)

    Number 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:

[ GitHub ]

  
# 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

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

Update a review request comment

Examples:

@client.update_pull_request_review('octokit/octokit.rb', 825, 6505518, 'This is close to perfect! Please address the suggested inline change. And add more about this.')

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    Number ID of the pull request

  • review (Integer)

    The id of the review

  • body (String)

    body text of the pull request review.

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

    Method options

Returns:

  • (Sawyer::Resource)

    Hash representing the review comment

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/reviews.rb', line 221

def update_pull_request_review(repo, number, review, body, options = {})
  options[:body] = body
  put "#{Repository.path repo}/pulls/#{number}/reviews/#{review}", options
end