Module: Octokit::Client::Pulls

Included in:
Octokit::Client
Defined in:
lib/octokit/client/pulls.rb

Instance Method Summary collapse

Instance Method Details

#create_pull_request(repo, base, head, title, body, options = {}) ⇒ Hashie::Mash

Create a pull request

Parameters:

  • repo (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)

    The body for the pull request. Supports GFM.

Returns:

  • (Hashie::Mash)

    The newly created pull request

See Also:



41
42
43
44
45
46
47
48
49
# File 'lib/octokit/client/pulls.rb', line 41

def create_pull_request(repo, base, head, title, body, options={})
  pull = {
    :base  => base,
    :head  => head,
    :title => title,
    :body  => body,
  }
  post("repos/#{Repository.new(repo)}/pulls", options.merge(pull))
end

#create_pull_request_comment(repo, pull_id, body, commit_id, path, position, options = {}) ⇒ Hashie::Mash Also known as: create_pull_comment, create_view_comment

Create a pull request comment

Examples:

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

Parameters:

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

  • position (Integer)

    Line index in the diff to comment on.

Returns:

  • (Hashie::Mash)

    Hash representing the new comment

See Also:



179
180
181
182
183
184
185
186
187
# File 'lib/octokit/client/pulls.rb', line 179

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("repos/#{Repository.new repo}/pulls/#{pull_id}/comments", options)
end

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

Create reply to a pull request comment

Examples:

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

Parameters:

  • repo (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:

  • (Hashie::Mash)

    Hash representing new comment

See Also:



201
202
203
204
205
206
207
# File 'lib/octokit/client/pulls.rb', line 201

def create_pull_request_comment_reply(repo, pull_id, body, comment_id, options={})
  options.merge!({
    :body => body,
    :in_reply_to => comment_id
  })
  post("repos/#{Repository.new repo}/pulls/#{pull_id}/comments", options)
end

#create_pull_request_for_issue(repo, base, head, issue, options = {}) ⇒ Hashie::Mash

Create a pull request from existing issue

Parameters:

  • repo (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:

  • (Hashie::Mash)

    The newly created pull request

See Also:



62
63
64
65
66
67
68
69
# File 'lib/octokit/client/pulls.rb', line 62

def create_pull_request_for_issue(repo, base, head, issue, options={})
  pull = {
    :base  => base,
    :head  => head,
    :issue => issue
  }
  post("repos/#{Repository.new(repo)}/pulls", options.merge(pull))
end

#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("pengwynn/octokit", 1902707)

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

  • comment_id (Integer)

    Id of the comment to delete

Returns:

  • (Boolean)

    True if deleted, false otherwise



234
235
236
# File 'lib/octokit/client/pulls.rb', line 234

def delete_pull_request_comment(repo, comment_id, options={})
  boolean_from_response(:delete, "repos/#{Repository.new repo}/pulls/comments/#{comment_id}", options)
end

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

Merge a pull request

Parameters:

  • repo (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<Hashie::Mash>)

    Merge commit info if successful

See Also:



258
259
260
# File 'lib/octokit/client/pulls.rb', line 258

def merge_pull_request(repo, number, commit_message='', options={})
  put("repos/#{Repository.new(repo)}/pulls/#{number}/merge", options.merge({:commit_message => commit_message}))
end

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

Check pull request merge status

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    Number of pull request

Returns:

  • (Boolean)

    True if the pull request has been merged

See Also:



268
269
270
# File 'lib/octokit/client/pulls.rb', line 268

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

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

Get a pull request

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    Number of the pull request to fetch

Returns:

  • (Hashie::Mash)

    Pull request info

See Also:



24
25
26
# File 'lib/octokit/client/pulls.rb', line 24

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

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

Get a pull request comment

Examples:

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

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

  • comment_id (Integer)

    Id of comment to get

Returns:

  • (Hashie::Mash)

    Hash representing the comment

See Also:



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

def pull_request_comment(repo, comment_id, options={})
  get("repos/#{Repository.new repo}/pulls/comments/#{comment_id}", options)
end

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

List comments on a pull request

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    Number of pull request

Returns:

  • (Array<Hashie::Mash>)

    List of comments

See Also:



145
146
147
148
# File 'lib/octokit/client/pulls.rb', line 145

def pull_request_comments(repo, number, options={})
  # return the comments for a pull request
  get("repos/#{Repository.new(repo)}/pulls/#{number}/comments", options)
end

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

List commits on a pull request

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    Number of pull request

Returns:

  • (Array<Hashie::Mash>)

    List of commits

See Also:



103
104
105
# File 'lib/octokit/client/pulls.rb', line 103

def pull_request_commits(repo, number, options={})
  get("repos/#{Repository.new(repo)}/pulls/#{number}/commits", options)
end

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

List files on a pull request

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

  • number (Integer)

    Number of pull request

Returns:

  • (Array<Hashie::Mash>)

    List of files

See Also:



246
247
248
# File 'lib/octokit/client/pulls.rb', line 246

def pull_request_files(repo, number, options={})
  get("repos/#{Repository.new(repo)}/pulls/#{number}/files", options)
end

#pull_requests(repo, state = 'open', options = {}) ⇒ Array<Hashie::Mash> Also known as: pulls

List pull requests for a repository

Examples:

Octokit.pull_requests('rails/rails')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

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

    Method options

Options Hash (options):

  • :state (String)

    ‘open` or `closed`. Default is `open`.

Returns:

  • (Array<Hashie::Mash>)

    Array of pulls

See Also:



13
14
15
# File 'lib/octokit/client/pulls.rb', line 13

def pull_requests(repo, state='open', options={})
  get("repos/#{Repository.new(repo)}/pulls", options.merge({:state => state}))
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("pengwynn/octokit")

Get review comments, sort by updated asc since a time

@client.pull_requests_comments("pengwynn/octokit", {
  :sort => 'asc',
  :direction => 'down',
  :since => '2010-05-04T23:45:02Z'
})

Parameters:

  • repo (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:



133
134
135
# File 'lib/octokit/client/pulls.rb', line 133

def pull_requests_comments(repo, options={})
  get("repos/#{Repository.new repo}/pulls/comments", options)
end

#update_pull_request(repo, id, title = nil, body = nil, state = nil, options = {}) ⇒ Hashie::Mash

Update a pull request

Examples:

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

Passing nil for optional attributes to update specific attributes.

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

Empty body by passing empty string

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

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

  • id (Integer)

    Id 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`.

Returns:

  • (Hashie::Mash)

    Hash representing updated pull request.

See Also:



86
87
88
89
90
91
92
93
94
# File 'lib/octokit/client/pulls.rb', line 86

def update_pull_request(repo, id, title=nil, body=nil, state=nil, options={})
  options.merge!({
    :title => title,
    :body => body,
    :state => state
  })
  options.reject! { |_, value| value.nil? }
  patch("repos/#{Repository.new repo}/pulls/#{id}", options)
end

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

Update pull request comment

Examples:

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

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

  • comment_id (Integer)

    Id of the comment to update

  • body (String)

    Updated comment content

Returns:

  • (Hashie::Mash)

    Hash representing the updated comment

See Also:



220
221
222
223
# File 'lib/octokit/client/pulls.rb', line 220

def update_pull_request_comment(repo, comment_id, body, options={})
  options.merge! :body => body
  patch("repos/#{Repository.new repo}/pulls/comments/#{comment_id}", options)
end