123456789_123456789_123456789_123456789_123456789_

Module: Octokit::Client::PullRequests

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

Overview

Methods for the Pull Requests API

Instance Method Summary

Instance Method Details

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

Close a pull request

Examples:

@client.close_pull_request('octokit/octokit.rb', 67)

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository.

  • number (Integer)

    Number of pull request to update.

Returns:

  • (Sawyer::Resource)

    Hash representing updated pull request.

See Also:

[ GitHub ]

  
# 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, line, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 218

alias create_pull_comment create_pull_request_comment

#create_pull_reply(repo, pull_id, body, comment_id, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 238

alias create_pull_reply   create_pull_request_comment_reply

#create_pull_request(repo, base, head, title, body = nil, options = {}) ⇒ Sawyer::Resource

Create a pull request

Examples:

@client.create_pull_request("octokit/octokit.rb", "master", "feature-branch",
  "Pull Request title", "Pull Request body")

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • 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.

  • head (String)

    The branch (or git ref) where your changes are implemented.

  • title (String)

    Title for the pull request

  • body (String) (defaults to: nil)

    The body for the pull request (optional). Supports GFM.

Returns:

  • (Sawyer::Resource)

    The newly created pull request

See Also:

[ GitHub ]

  
# 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, line, options = {}) ⇒ Sawyer::Resource Also known as: #create_pull_comment, #create_view_comment

Deprecated.

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

Create a pull request comment

Examples:

@client.create_pull_request_comment("octokit/octokit.rb", 163, ":shipit:",
  "2d3201e4440903d8b04a5487842053ca4883e5f0", "lib/octokit/request.rb", 47)

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • pull_id (Integer)

    Pull request id

  • body (String)

    Comment content

  • commit_id (String)

    Sha of the commit to comment on.

  • path (String)

    Relative path of the file to comment on.

  • line (Integer)

    Line index in the diff to comment on. For a multi-line comment, the last line of the range and specify 'start_line' in the 'options'.

Returns:

  • (Sawyer::Resource)

    Hash representing the new comment

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 209

def create_pull_request_comment(repo, pull_id, body, commit_id, path, line, options = {})
  options.merge!({
                   body: body,
                   commit_id: commit_id,
                   path: path,
                   line: line
                 })
  post "#{Repository.path repo}/pulls/#{pull_id}/comments", options
end

#create_pull_request_comment_reply(repo, pull_id, body, comment_id, options = {}) ⇒ Sawyer::Resource Also known as: #create_pull_reply, #create_review_reply

Create reply to a pull request comment

Examples:

@client.create_pull_request_comment_reply("octokit/octokit.rb", 163, "done.", 1903950)

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • pull_id (Integer)

    Pull request id

  • body (String)

    Comment contents

  • comment_id (Integer)

    Comment id to reply to

Returns:

  • (Sawyer::Resource)

    Hash representing new comment

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 231

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 = {}) ⇒ Sawyer::Resource

Create a pull request from existing issue

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • 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.

  • head (String)

    The branch (or git ref) where your changes are implemented.

  • issue (Integer)

    Number of Issue on which to base this pull request

Returns:

  • (Sawyer::Resource)

    The newly created pull request

See Also:

[ GitHub ]

  
# 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 = {})

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 239

alias create_review_reply create_pull_request_comment_reply

#create_view_comment(repo, pull_id, body, commit_id, path, line, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 219

alias create_view_comment create_pull_request_comment

#delete_pull_comment(repo, comment_id, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 268

alias delete_pull_comment   delete_pull_request_comment

#delete_pull_request_comment(repo, comment_id, options = {}) ⇒ Boolean Also known as: #delete_pull_comment, #delete_review_comment

Delete pull request comment

Examples:

@client.delete_pull_request_comment("octokit/octokit.rb", 1902707)

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • comment_id (Integer)

    Id of the comment to delete

Returns:

  • (Boolean)

    True if deleted, false otherwise

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 265

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 = {})

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 269

alias delete_review_comment delete_pull_request_comment

#merge_pull_request(repo, number, commit_message = '', options = {}) ⇒ Array<Sawyer::Resource>

Merge a pull request

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    Number of pull request

  • commit_message (String) (defaults to: '')

    Optional commit message for the merge commit

Returns:

  • (Array<Sawyer::Resource>)

    Merge commit info if successful

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 300

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.

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 35

alias pull pull_request

#pull_comment(repo, comment_id, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 190

alias pull_comment   pull_request_comment

#pull_comments(repo, number, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 176

alias pull_comments   pull_request_comments

#pull_commits(repo, number, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 133

alias pull_commits pull_request_commits

#pull_files(repo, number, options = {})

Alias for #pull_request_files.

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 280

alias pull_files pull_request_files

#pull_merged?(repo, number, options = {}) ⇒ Boolean Also known as: #pull_request_merged?

Check pull request merge status

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    Number of pull request

Returns:

  • (Boolean)

    True if the pull request has been merged

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 310

def pull_merged?(repo, number, options = {})
  boolean_from_response :get, "#{Repository.path repo}/pulls/#{number}/merge", options
end

#pull_request(repo, number, options = {}) ⇒ Sawyer::Resource Also known as: #pull

Get a pull request

Examples:

Octokit.pull_request('rails/rails', 42, :state => 'closed')

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    Number of the pull request to fetch

Returns:

  • (Sawyer::Resource)

    Pull request info

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 32

def pull_request(repo, number, options = {})
  get "#{Repository.path repo}/pulls/#{number}", options
end

#pull_request_comment(repo, comment_id, options = {}) ⇒ Sawyer::Resource Also known as: #pull_comment, #review_comment

Get a pull request comment

Examples:

@client.pull_request_comment("pengwynn/octkit", 1903950)

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • comment_id (Integer)

    Id of comment to get

Returns:

  • (Sawyer::Resource)

    Hash representing the comment

See Also:

[ GitHub ]

  
# 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

#pull_request_comments(repo, number, options = {}) ⇒ Array<Sawyer::Resource> Also known as: #pull_comments, #review_comments

List comments on a pull request

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    Number of pull request

Returns:

  • (Array<Sawyer::Resource>)

    List of comments

See Also:

[ GitHub ]

  
# 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

#pull_request_commits(repo, number, options = {}) ⇒ Array<Sawyer::Resource> Also known as: #pull_commits

List commits on a pull request

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    Number of pull request

Returns:

  • (Array<Sawyer::Resource>)

    List of commits

See Also:

[ GitHub ]

  
# 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

#pull_request_files(repo, number, options = {}) ⇒ Array<Sawyer::Resource> Also known as: #pull_files

List files on a pull request

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    Number of pull request

Returns:

  • (Array<Sawyer::Resource>)

    List of files

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 277

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

#pull_request_merged?(repo, number, options = {})

Alias for #pull_merged?.

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 313

alias pull_request_merged? pull_merged?

#pull_requests(repo, options) ⇒ Array<Sawyer::Resource> Also known as: #pulls

List pull requests for a repository

Examples:

Octokit.pull_requests('rails/rails', :state => 'closed')

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • options (Hash)

    Method options

Options Hash (options):

  • :state (String)

    open or closed or all.

Returns:

  • (Array<Sawyer::Resource>)

    Array of pulls

See Also:

[ GitHub ]

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

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

#pull_requests_comments(repo, options = {}) ⇒ Array Also known as: #pulls_comments, #reviews_comments

List pull request comments for a repository

By default, Review Comments are ordered by ascending ID.

Examples:

Get the pull request review comments in the octokit repository

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

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'
})

Parameters:

  • repo (Integer, String, Repository, Hash)

    A GitHub repository

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

    Optional parameters

Options Hash (options):

  • :sort (String)

    created or updated

  • :direction (String)

    asc or desc. Ignored without sort parameter.

  • :since (String)

    Timestamp in ISO 8601 format: YYYY-MM-DDTHH:MM:SSZ

Returns:

  • (Array)

    List of pull request review comments.

See Also:

[ GitHub ]

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

def pull_requests_comments(repo, options = {})
  paginate("#{Repository.path repo}/pulls/comments", options)
end

#pulls(repo, options = {})

Alias for #pull_requests.

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 22

alias pulls pull_requests

#pulls_comments(repo, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 163

alias pulls_comments   pull_requests_comments

#review_comment(repo, comment_id, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 191

alias review_comment pull_request_comment

#review_comments(repo, number, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 177

alias review_comments pull_request_comments

#reviews_comments(repo, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 164

alias reviews_comments pull_requests_comments

#update_pull_comment(repo, comment_id, body, options = {})

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 254

alias update_pull_comment   update_pull_request_comment

#update_pull_request(repo, number, title = nil, body = nil, state = nil, options = {}) ⇒ Sawyer::Resource #update_pull_request(repo, number, options = {}) ⇒ Sawyer::Resource

Update a pull request

Examples:

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

Passing nil for optional attributes to update specific attributes.

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

Empty body by passing empty string

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

Overloads:

  • #update_pull_request(repo, number, title = nil, body = nil, state = nil, options = {}) ⇒ Sawyer::Resource
    Deprecated.

    Parameters:

    • repo (Integer, String, Hash, Repository)

      A GitHub repository.

    • number (Integer)

      Number of pull request to update.

    • title (String) (defaults to: nil)

      Title for the pull request.

    • body (String) (defaults to: nil)

      Body content for pull request. Supports GFM.

    • state (String) (defaults to: nil)

      State of the pull request. open or closed.

  • #update_pull_request(repo, number, options = {}) ⇒ Sawyer::Resource

    Parameters:

    • repo (Integer, String, Hash, Repository)

      A GitHub repository.

    • number (Integer)

      Number of pull request to update.

    Options Hash (options):

    • :title (String)

      Title for the pull request.

    • :body (String)

      Body for the pull request.

    • :state (String)

      State for the pull request.

Returns:

  • (Sawyer::Resource)

    Hash representing updated pull request.

See Also:

[ GitHub ]

  
# 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_branch(repo, number, options = {}) ⇒ Boolean

Update a pull request branch

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    Number of pull request

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

    Optional parameters (e.g. expected_head_sha)

Returns:

  • (Boolean)

    True if the pull request branch has been updated

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 289

def update_pull_request_branch(repo, number, options = {})
  boolean_from_response(:put, "#{Repository.path repo}/pulls/#{number}/update-branch", options)
end

#update_pull_request_comment(repo, comment_id, body, options = {}) ⇒ Sawyer::Resource Also known as: #update_pull_comment, #update_review_comment

Update pull request comment

Examples:

@client.update_pull_request_comment("octokit/octokit.rb", 1903950, ":shipit:")

Parameters:

  • repo (Integer, String, Hash, Repository)

    A GitHub repository

  • comment_id (Integer)

    Id of the comment to update

  • body (String)

    Updated comment content

Returns:

  • (Sawyer::Resource)

    Hash representing the updated comment

See Also:

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 250

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 = {})

[ GitHub ]

  
# File 'lib/octokit/client/pull_requests.rb', line 255

alias update_review_comment update_pull_request_comment