module Octokit::Client::PullRequests

def close_pull_request(repo, number, options = {})

Other tags:
    See: https://developer.github.com/v3/pulls/#update-a-pull-request -

Returns:
  • (Sawyer::Resource) - Hash representing updated pull request.

Parameters:
  • number (Integer) -- Number of pull request to update.
  • repo (Integer, String, Hash, Repository) -- A GitHub repository.
def close_pull_request(repo, number, options = {})
  options.merge! state: 'closed'
  update_pull_request(repo, number, options)
end

def create_pull_request(repo, base, head, title, body = nil, options = {})

Returns:
  • (Sawyer::Resource) - The newly created pull request

Parameters:
  • body (String) -- The body for the pull request (optional). Supports GFM.
  • title (String) -- Title for the pull request
  • head (String) -- The branch (or git ref) where your changes are implemented.
  • base (String) -- The branch (or git ref) you want your changes
  • repo (Integer, String, Hash, Repository) -- A GitHub repository

Other tags:
    See: https://developer.github.com/v3/pulls/#create-a-pull-request -
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

def create_pull_request_comment(repo, pull_id, body, commit_id, path, line = nil, options = {})

Other tags:
    See: https://developer.github.com/v3/pulls/comments/#create-a-comment -

Deprecated:
  • The position will be deprecated in the next major version. Please refer to the details below.

Returns:
  • (Sawyer::Resource) - Hash representing the new comment

Parameters:
  • line (Integer) -- Optional line index in the diff to comment on.
  • path (String) -- Relative path of the file to comment on.
  • commit_id (String) -- Sha of the commit to comment on.
  • body (String) -- Comment content
  • pull_id (Integer) -- Pull request id
  • repo (Integer, String, Hash, Repository) -- A GitHub repository
def create_pull_request_comment(repo, pull_id, body, commit_id, path, line = nil, options = {})
  comment = {
    body: body,
    commit_id: commit_id,
    path: path
  }
  if line.nil?
    comment[:subject_type] = 'file'
  else
    comment[:line] = line
  end
  options.merge! comment
  post "#{Repository.path repo}/pulls/#{pull_id}/comments", options
end

def create_pull_request_comment_reply(repo, pull_id, body, comment_id, options = {})

Other tags:
    See: https://developer.github.com/v3/pulls/comments/#create-a-comment -

Returns:
  • (Sawyer::Resource) - Hash representing new comment

Parameters:
  • comment_id (Integer) -- Comment id to reply to
  • body (String) -- Comment contents
  • pull_id (Integer) -- Pull request id
  • repo (Integer, String, Hash, Repository) -- A GitHub repository
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

def create_pull_request_for_issue(repo, base, head, issue, options = {})

Returns:
  • (Sawyer::Resource) - The newly created pull request

Parameters:
  • issue (Integer) -- Number of Issue on which to base this pull request
  • head (String) -- The branch (or git ref) where your changes are implemented.
  • base (String) -- The branch (or git ref) you want your changes
  • repo (Integer, String, Hash, Repository) -- A GitHub repository

Other tags:
    See: https://developer.github.com/v3/pulls/#alternative-input -
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

def delete_pull_request_comment(repo, comment_id, options = {})

Other tags:
    See: https://developer.github.com/v3/pulls/comments/#delete-a-comment -

Returns:
  • (Boolean) - True if deleted, false otherwise

Parameters:
  • comment_id (Integer) -- Id of the comment to delete
  • repo (Integer, String, Hash, Repository) -- A GitHub repository
def delete_pull_request_comment(repo, comment_id, options = {})
  boolean_from_response(:delete, "#{Repository.path repo}/pulls/comments/#{comment_id}", options)
end

def merge_pull_request(repo, number, commit_message = '', options = {})

Returns:
  • (Array) - Merge commit info if successful

Parameters:
  • commit_message (String) -- Optional commit message for the merge commit
  • number (Integer) -- Number of pull request
  • repo (Integer, String, Hash, Repository) -- A GitHub repository

Other tags:
    See: https://developer.github.com/v3/pulls/#merge-a-pull-request-merge-button -
def merge_pull_request(repo, number, commit_message = '', options = {})
  put "#{Repository.path repo}/pulls/#{number}/merge", options.merge({ commit_message: commit_message })
end

def pull_merged?(repo, number, options = {})

Returns:
  • (Boolean) - True if the pull request has been merged

Parameters:
  • number (Integer) -- Number of pull request
  • repo (Integer, String, Hash, Repository) -- A GitHub repository

Other tags:
    See: https://developer.github.com/v3/pulls/#get-if-a-pull-request-has-been-merged -
def pull_merged?(repo, number, options = {})
  boolean_from_response :get, "#{Repository.path repo}/pulls/#{number}/merge", options
end

def pull_request(repo, number, options = {})

Returns:
  • (Sawyer::Resource) - Pull request info

Parameters:
  • number (Integer) -- Number of the pull request to fetch
  • repo (Integer, String, Hash, Repository) -- A GitHub repository

Other tags:
    See: https://developer.github.com/v3/pulls/#get-a-single-pull-request -
def pull_request(repo, number, options = {})
  get "#{Repository.path repo}/pulls/#{number}", options
end

def pull_request_comment(repo, comment_id, options = {})

Other tags:
    See: https://developer.github.com/v3/pulls/comments/#get-a-single-comment -

Returns:
  • (Sawyer::Resource) - Hash representing the comment

Parameters:
  • comment_id (Integer) -- Id of comment to get
  • repo (Integer, String, Hash, Repository) -- A GitHub repository
def pull_request_comment(repo, comment_id, options = {})
  get "#{Repository.path repo}/pulls/comments/#{comment_id}", options
end

def pull_request_comments(repo, number, options = {})

Returns:
  • (Array) - List of comments

Parameters:
  • number (Integer) -- Number of pull request
  • repo (Integer, String, Hash, Repository) -- A GitHub repository

Other tags:
    See: https://developer.github.com/v3/pulls/comments/#list-comments-on-a-pull-request -
def pull_request_comments(repo, number, options = {})
  # return the comments for a pull request
  paginate("#{Repository.path repo}/pulls/#{number}/comments", options)
end

def pull_request_commits(repo, number, options = {})

Returns:
  • (Array) - List of commits

Parameters:
  • number (Integer) -- Number of pull request
  • repo (Integer, String, Hash, Repository) -- A GitHub repository

Other tags:
    See: https://developer.github.com/v3/pulls/#list-commits-on-a-pull-request -
def pull_request_commits(repo, number, options = {})
  paginate "#{Repository.path repo}/pulls/#{number}/commits", options
end

def pull_request_files(repo, number, options = {})

Returns:
  • (Array) - List of files

Parameters:
  • number (Integer) -- Number of pull request
  • repo (Integer, String, Hash, Repository) -- A GitHub repository

Other tags:
    See: https://developer.github.com/v3/pulls/#list-pull-requests-files -
def pull_request_files(repo, number, options = {})
  paginate "#{Repository.path repo}/pulls/#{number}/files", options
end

def pull_requests(repo, options = {})

Other tags:
    See: https://developer.github.com/v3/pulls/#list-pull-requests -

Returns:
  • (Array) - Array of pulls

Options Hash: (**options)
  • :state (String) -- `open` or `closed` or `all`.

Parameters:
  • options (Hash) -- Method options
  • repo (Integer, String, Hash, Repository) -- A GitHub repository

Overloads:
  • pull_requests(repo, options)
def pull_requests(repo, options = {})
  paginate "#{Repository.path repo}/pulls", options
end

def pull_requests_comments(repo, options = {})

Other tags:
    Example: Get review comments, sort by updated asc since a time -
    Example: Get the pull request review comments in the octokit repository -

Other tags:
    See: https://developer.github.com/v3/pulls/comments/#list-comments-in-a-repository -

Returns:
  • (Array) - List of pull request review comments.

Options Hash: (**options)
  • :since (String) -- Timestamp in ISO 8601
  • :direction (String) -- asc or desc. Ignored without sort
  • :sort (String) -- created or updated

Parameters:
  • options (Hash) -- Optional parameters
  • repo (Integer, String, Repository, Hash) -- A GitHub repository
def pull_requests_comments(repo, options = {})
  paginate("#{Repository.path repo}/pulls/comments", options)
end

def update_pull_request(*args)

Other tags:
    Example: Empty body by passing empty string -
    Example: Passing nil for optional attributes to update specific attributes. -

Other tags:
    See: https://developer.github.com/v3/pulls/#update-a-pull-request -

Returns:
  • (Sawyer::Resource) - Hash representing updated pull request.

Options Hash: (**options)
  • :state (String) -- State for the pull request.
  • :body (String) -- Body for the pull request.
  • :title (String) -- Title for the pull request.

Parameters:
  • number (Integer) -- Number of pull request to update.
  • repo (Integer, String, Hash, Repository) -- A GitHub repository.
  • state (String) -- State of the pull request. `open` or `closed`.
  • body (String) -- Body content for pull request. Supports GFM.
  • title (String) -- Title for the pull request.
  • number (Integer) -- Number of pull request to update.
  • repo (Integer, String, Hash, Repository) -- A GitHub repository.

Overloads:
  • update_pull_request(repo, number, options = {})
  • update_pull_request(repo, number, title=nil, body=nil, state=nil, options = {})

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

def update_pull_request_branch(repo, number, options = {})

Returns:
  • (Boolean) - True if the pull request branch has been updated

Parameters:
  • options (Hash) -- Optional parameters (e.g. expected_head_sha)
  • number (Integer) -- Number of pull request
  • repo (Integer, String, Hash, Repository) -- A GitHub repository

Other tags:
    See: https://developer.github.com/v3/pulls/#update-a-pull-request-branch -
def update_pull_request_branch(repo, number, options = {})
  boolean_from_response(:put, "#{Repository.path repo}/pulls/#{number}/update-branch", options)
end

def update_pull_request_comment(repo, comment_id, body, options = {})

Other tags:
    See: https://developer.github.com/v3/pulls/comments/#edit-a-comment -

Returns:
  • (Sawyer::Resource) - Hash representing the updated comment

Parameters:
  • body (String) -- Updated comment content
  • comment_id (Integer) -- Id of the comment to update
  • repo (Integer, String, Hash, Repository) -- A GitHub repository
def update_pull_request_comment(repo, comment_id, body, options = {})
  options.merge! body: body
  patch("#{Repository.path repo}/pulls/comments/#{comment_id}", options)
end