module Octokit::Client::PullRequests

Methods for the Pull Requests API

@see developer.github.com/v3/pulls/

Public Instance Methods

close_pull_request(repo, number, options = {}) click to toggle source

Close a pull request

@param repo [Integer, String, Hash, Repository] A GitHub repository. @param number [Integer] Number of pull request to update. @return [Sawyer::Resource] Hash representing updated pull request. @see developer.github.com/v3/pulls/#update-a-pull-request @example

@client.close_pull_request('octokit/octokit.rb', 67)
# File lib/octokit/client/pull_requests.rb, line 119
def close_pull_request(repo, number, options = {})
  options.merge! :state => 'closed'
  update_pull_request(repo, number, options)
end
create_pull_comment(repo, pull_id, body, commit_id, path, position, options = {})
create_pull_reply(repo, pull_id, body, comment_id, options = {})
create_pull_request(repo, base, head, title, body = nil, options = {}) click to toggle source

Create a pull request

@see developer.github.com/v3/pulls/#create-a-pull-request @param repo [Integer, String, Hash, Repository] A GitHub repository @param base [String] The branch (or git ref) you want your changes

pulled into. This should be an existing branch on the current
repository. You cannot submit a pull request to one repo that requests
a merge to a base of another repo.

@param head [String] The branch (or git ref) where your changes are implemented. @param title [String] Title for the pull request @param body [String] The body for the pull request (optional). Supports GFM. @return [Sawyer::Resource] The newly created pull request @example

@client.create_pull_request("octokit/octokit.rb", "master", "feature-branch",
  "Pull Request title", "Pull Request body")
# File lib/octokit/client/pull_requests.rb, line 52
def create_pull_request(repo, base, head, title, body = nil, options = {})
  pull = {
    :base  => base,
    :head  => head,
    :title => title,
  }
  pull[:body] = body unless body.nil?
  post "#{Repository.path repo}/pulls", options.merge(pull)
end
create_pull_request_comment(repo, pull_id, body, commit_id, path, position, options = {}) click to toggle source

Create a pull request comment

@param repo [Integer, String, Hash, Repository] A GitHub repository @param pull_id [Integer] Pull request id @param body [String] Comment content @param commit_id [String] Sha of the commit to comment on. @param path [String] Relative path of the file to comment on. @param position [Integer] Line index in the diff to comment on. @return [Sawyer::Resource] Hash representing the new comment @see developer.github.com/v3/pulls/comments/#create-a-comment @example

@client.create_pull_request_comment("octokit/octokit.rb", 163, ":shipit:",
  "2d3201e4440903d8b04a5487842053ca4883e5f0", "lib/octokit/request.rb", 47)
# File lib/octokit/client/pull_requests.rb, line 206
def create_pull_request_comment(repo, pull_id, body, commit_id, path, position, options = {})
  options.merge!({
    :body => body,
    :commit_id => commit_id,
    :path => path,
    :position => position
  })
  post "#{Repository.path repo}/pulls/#{pull_id}/comments", options
end
create_pull_request_comment_reply(repo, pull_id, body, comment_id, options = {}) click to toggle source

Create reply to a pull request comment

@param repo [Integer, String, Hash, Repository] A GitHub repository @param pull_id [Integer] Pull request id @param body [String] Comment contents @param comment_id [Integer] Comment id to reply to @return [Sawyer::Resource] Hash representing new comment @see developer.github.com/v3/pulls/comments/#create-a-comment @example

@client.create_pull_request_comment_reply("octokit/octokit.rb", 163, "done.", 1903950)
# File lib/octokit/client/pull_requests.rb, line 228
def create_pull_request_comment_reply(repo, pull_id, body, comment_id, options = {})
  options.merge!({
    :body => body,
    :in_reply_to => comment_id
  })
  post "#{Repository.path repo}/pulls/#{pull_id}/comments", options
end
create_pull_request_for_issue(repo, base, head, issue, options = {}) click to toggle source

Create a pull request from existing issue

@see developer.github.com/v3/pulls/#alternative-input @param repo [Integer, String, Hash, Repository] A GitHub repository @param base [String] The branch (or git ref) you want your changes

pulled into. This should be an existing branch on the current
repository. You cannot submit a pull request to one repo that requests
a merge to a base of another repo.

@param head [String] The branch (or git ref) where your changes are implemented. @param issue [Integer] Number of Issue on which to base this pull request @return [Sawyer::Resource] The newly created pull request

# File lib/octokit/client/pull_requests.rb, line 73
def create_pull_request_for_issue(repo, base, head, issue, options = {})
  pull = {
    :base  => base,
    :head  => head,
    :issue => issue
  }
  post "#{Repository.path repo}/pulls", options.merge(pull)
end
create_review_reply(repo, pull_id, body, comment_id, options = {})
create_view_comment(repo, pull_id, body, commit_id, path, position, options = {})
delete_pull_comment(repo, comment_id, options = {})
delete_pull_request_comment(repo, comment_id, options = {}) click to toggle source

Delete pull request comment

@param repo [Integer, String, Hash, Repository] A GitHub repository @param comment_id [Integer] Id of the comment to delete @return [Boolean] True if deleted, false otherwise @see developer.github.com/v3/pulls/comments/#delete-a-comment @example

@client.delete_pull_request_comment("octokit/octokit.rb", 1902707)
# File lib/octokit/client/pull_requests.rb, line 262
def delete_pull_request_comment(repo, comment_id, options = {})
  boolean_from_response(:delete, "#{Repository.path repo}/pulls/comments/#{comment_id}", options)
end
delete_review_comment(repo, comment_id, options = {})
merge_pull_request(repo, number, commit_message='', options = {}) click to toggle source

Merge a pull request

@see developer.github.com/v3/pulls/#merge-a-pull-request-merge-button @param repo [Integer, String, Hash, Repository] A GitHub repository @param number [Integer] Number of pull request @param commit_message [String] Optional commit message for the merge commit @return [Array<Sawyer::Resource>] Merge commit info if successful

# File lib/octokit/client/pull_requests.rb, line 286
def merge_pull_request(repo, number, commit_message='', options = {})
  put "#{Repository.path repo}/pulls/#{number}/merge", options.merge({:commit_message => commit_message})
end
pull(repo, number, options = {})
Alias for: pull_request
pull_comment(repo, comment_id, options = {})
pull_comments(repo, number, options = {})
pull_commits(repo, number, options = {})
pull_files(repo, number, options = {})
Alias for: pull_request_files
pull_merged?(repo, number, options = {}) click to toggle source

Check pull request merge status

@see developer.github.com/v3/pulls/#get-if-a-pull-request-has-been-merged @param repo [Integer, String, Hash, Repository] A GitHub repository @param number [Integer] Number of pull request @return [Boolean] True if the pull request has been merged

# File lib/octokit/client/pull_requests.rb, line 296
def pull_merged?(repo, number, options = {})
  boolean_from_response :get, "#{Repository.path repo}/pulls/#{number}/merge", options
end
Also aliased as: pull_request_merged?
pull_request(repo, number, options = {}) click to toggle source

Get a pull request

@see developer.github.com/v3/pulls/#get-a-single-pull-request @param repo [Integer, String, Hash, Repository] A GitHub repository @param number [Integer] Number of the pull request to fetch @return [Sawyer::Resource] Pull request info @example

Octokit.pull_request('rails/rails', 42, :state => 'closed')
# File lib/octokit/client/pull_requests.rb, line 32
def pull_request(repo, number, options = {})
  get "#{Repository.path repo}/pulls/#{number}", options
end
Also aliased as: pull
pull_request_comment(repo, comment_id, options = {}) click to toggle source

Get a pull request comment

@param repo [Integer, String, Hash, Repository] A GitHub repository @param comment_id [Integer] Id of comment to get @return [Sawyer::Resource] Hash representing the comment @see developer.github.com/v3/pulls/comments/#get-a-single-comment @example

@client.pull_request_comment("pengwynn/octkit", 1903950)
# File lib/octokit/client/pull_requests.rb, line 187
def pull_request_comment(repo, comment_id, options = {})
  get "#{Repository.path repo}/pulls/comments/#{comment_id}", options
end
Also aliased as: pull_comment, review_comment
pull_request_comments(repo, number, options = {}) click to toggle source

List comments on a pull request

@see developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request @param repo [Integer, String, Hash, Repository] A GitHub repository @param number [Integer] Number of pull request @return [Array<Sawyer::Resource>] List of comments

# File lib/octokit/client/pull_requests.rb, line 172
def pull_request_comments(repo, number, options = {})
  # return the comments for a pull request
  paginate("#{Repository.path repo}/pulls/#{number}/comments", options)
end
Also aliased as: pull_comments, review_comments
pull_request_commits(repo, number, options = {}) click to toggle source

List commits on a pull request

@see developer.github.com/v3/pulls/#list-commits-on-a-pull-request @param repo [Integer, String, Hash, Repository] A GitHub repository @param number [Integer] Number of pull request @return [Array<Sawyer::Resource>] List of commits

# File lib/octokit/client/pull_requests.rb, line 130
def pull_request_commits(repo, number, options = {})
  paginate "#{Repository.path repo}/pulls/#{number}/commits", options
end
Also aliased as: pull_commits
pull_request_files(repo, number, options = {}) click to toggle source

List files on a pull request

@see developer.github.com/v3/pulls/#list-pull-requests-files @param repo [Integer, String, Hash, Repository] A GitHub repository @param number [Integer] Number of pull request @return [Array<Sawyer::Resource>] List of files

# File lib/octokit/client/pull_requests.rb, line 274
def pull_request_files(repo, number, options = {})
  paginate "#{Repository.path repo}/pulls/#{number}/files", options
end
Also aliased as: pull_files
pull_request_merged?(repo, number, options = {})
Alias for: pull_merged?
pull_requests(repo, options = {}) click to toggle source

List pull requests for a repository

@overload pull_requests(repo, options)

@param repo [Integer, String, Hash, Repository] A GitHub repository
@param options [Hash] Method options
@option options [String] :state `open` or `closed` or `all`.

@return [Array<Sawyer::Resource>] Array of pulls @see developer.github.com/v3/pulls/#list-pull-requests @example

Octokit.pull_requests('rails/rails', :state => 'closed')
# File lib/octokit/client/pull_requests.rb, line 19
def pull_requests(repo, options = {})
  paginate "#{Repository.path repo}/pulls", options
end
Also aliased as: pulls
pull_requests_comments(repo, options = {}) click to toggle source

List pull request comments for a repository

By default, Review Comments are ordered by ascending ID.

@param repo [Integer, String, Repository, Hash] A GitHub repository @param options [Hash] Optional parameters @option options [String] :sort created or updated @option options [String] :direction asc or desc. Ignored without sort

parameter.

@option options [String] :since Timestamp in ISO 8601

format: YYYY-MM-DDTHH:MM:SSZ

@return [Array] List of pull request review comments.

@see developer.github.com/v3/pulls/comments/#list-comments-in-a-repository

@example Get the pull request review comments in the octokit repository

@client.issues_comments("octokit/octokit.rb")

@example Get review comments, sort by updated asc since a time

@client.pull_requests_comments("octokit/octokit.rb", {
  :sort => 'updated',
  :direction => 'asc',
  :since => '2010-05-04T23:45:02Z'
})
# File lib/octokit/client/pull_requests.rb, line 160
def pull_requests_comments(repo, options = {})
  paginate("#{Repository.path repo}/pulls/comments", options)
end
Also aliased as: pulls_comments, reviews_comments
pulls(repo, options = {})
Alias for: pull_requests
pulls_comments(repo, options = {})
review_comment(repo, comment_id, options = {})
review_comments(repo, number, options = {})
reviews_comments(repo, options = {})
update_pull_comment(repo, comment_id, body, options = {})
update_pull_request(*args) click to toggle source

Update a pull request @overload update_pull_request(repo, number, title=nil, body=nil, state=nil, options = {})

@deprecated
@param repo [Integer, String, Hash, Repository] A GitHub repository.
@param number [Integer] Number of pull request to update.
@param title [String] Title for the pull request.
@param body [String] Body content for pull request. Supports GFM.
@param state [String] State of the pull request. `open` or `closed`.

@overload update_pull_request(repo, number, options = {})

@param repo [Integer, String, Hash, Repository] A GitHub repository.
@param number [Integer] Number of pull request to update.
@option options [String] :title Title for the pull request.
@option options [String] :body Body for the pull request.
@option options [String] :state State for the pull request.

@return [Sawyer::Resource] Hash representing updated pull request. @see developer.github.com/v3/pulls/#update-a-pull-request @example

@client.update_pull_request('octokit/octokit.rb', 67, 'new title', 'updated body', 'closed')

@example Passing nil for optional attributes to update specific attributes.

@client.update_pull_request('octokit/octokit.rb', 67, nil, nil, 'open')

@example Empty body by passing empty string

@client.update_pull_request('octokit/octokit.rb', 67, nil, '')
# File lib/octokit/client/pull_requests.rb, line 104
def update_pull_request(*args)
  arguments = Octokit::Arguments.new(args)
  repo   = arguments.shift
  number = arguments.shift
  patch "#{Repository.path repo}/pulls/#{number}", arguments.options
end
update_pull_request_comment(repo, comment_id, body, options = {}) click to toggle source

Update pull request comment

@param repo [Integer, String, Hash, Repository] A GitHub repository @param comment_id [Integer] Id of the comment to update @param body [String] Updated comment content @return [Sawyer::Resource] Hash representing the updated comment @see developer.github.com/v3/pulls/comments/#edit-a-comment @example

@client.update_pull_request_comment("octokit/octokit.rb", 1903950, ":shipit:")
# File lib/octokit/client/pull_requests.rb, line 247
def update_pull_request_comment(repo, comment_id, body, options = {})
  options.merge! :body => body
  patch("#{Repository.path repo}/pulls/comments/#{comment_id}", options)
end
update_review_comment(repo, comment_id, body, options = {})