Module: GitHub::Client::PullRequests

Included in:
GitHub::Client
Defined in:
lib/github_api_v3/client/pull_requests.rb

Overview

Methods for the Pull Requests API.

Instance Method Summary collapse

Instance Method Details

#create_pull_request(owner, repo, options = {}) ⇒ Hash

Create a new pull request.

Requires authentication.

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. your changes are implemented.

Examples:

client.create_pull_request(
  'caseyscarborough',
  'github', 
  title: 'New pull request.', 
  head: 'caseyscarborough:new-feature', 
  base: 'master'
)

Parameters:

  • owner (String)

    Repository owner.

  • repo (String)

    Repository name.

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

    Options.

Options Hash (options):

  • :title (String) — default: required

    The pull request title.

  • :body (String)
  • :base (String) — default: required

    The branch (or git ref) you

  • :head (String) — default: required

    The branch (or git ref) where

Returns:

  • (Hash)

    The pull request information.

See Also:



58
59
60
# File 'lib/github_api_v3/client/pull_requests.rb', line 58

def create_pull_request(owner, repo, options={})
  post "/repos/#{owner}/#{repo}/pulls", body: options
end

#create_pull_request_comment(owner, repo, number, options = {}) ⇒ Hash

Create a pull request comment.

Requires authentication.

Examples:

client.create_pull_request_comment(
  'caseyscarborough',
  'github',
  3,
  body: 'Very nice!',
  commit_id: 'cbe5c38e933022534ea85c3c7e2596f1bb90fe8e',
  path: 'README.md',
  position: 2
)

Parameters:

  • owner (String)

    Repository owner.

  • repo (String)

    Repository name.

  • number (Integer)

    Pull request number.

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

    Parameters.

Options Hash (options):

  • :body (String) — default: required

    Comment body.

  • :commit_id (String) — default: required

    Sha of the commit to comment on.

  • :path (String) — default: required

    Relative path of the file to comment on.

  • :position (Integer) — default: required

    Line index in the diff to comment on.

Returns:

  • (Hash)

    Comment information.

See Also:



183
184
185
# File 'lib/github_api_v3/client/pull_requests.rb', line 183

def create_pull_request_comment(owner, repo, number, options={})
  post "/repos/#{owner}/#{repo}/pulls/#{number}/comments", body: options
end

#delete_pull_request_comment(owner, repo, number) ⇒ Object

Delete a pull request comment.

Requires authentication.

Examples:

client.delete_pull_request_comment('caseyscarborough', 'github', 1242348)

Parameters:

  • owner (String)

    Repository owner.

  • repo (String)

    Repository name.

  • number (Integer)

    Comment number.

See Also:



214
215
216
# File 'lib/github_api_v3/client/pull_requests.rb', line 214

def delete_pull_request_comment(owner, repo, number)
  boolean_request :delete, "/repos/#{owner}/#{repo}/pulls/comments/#{number}"
end

#edit_pull_request_comment(owner, repo, number, body) ⇒ Hash

Edit a pull request comment.

Requires authentication.

Examples:

client.edit_pull_request_comment('caseyscarborough', 'github', 1242348, 'What up, girl?')

Parameters:

  • owner (String)

    Repository owner.

  • repo (String)

    Repository name.

  • number (Integer)

    Comment number.

  • body (String)

    New comment body.

Returns:

  • (Hash)

    Comment information.

See Also:



199
200
201
202
# File 'lib/github_api_v3/client/pull_requests.rb', line 199

def edit_pull_request_comment(owner, repo, number, body)
  options = { body: body }
  patch "/repos/#{owner}/#{repo}/pulls/comments/#{number}", body: options
end

#merge_pull_request(owner, repo, number) ⇒ Hash

Merge a pull request.

Requires authentication.

Parameters:

  • owner (String)

    Repository owner.

  • repo (String)

    Repository name.

  • number (Integer)

    The pull request number.

Returns:

  • (Hash)

    Merge information.

See Also:



121
122
123
# File 'lib/github_api_v3/client/pull_requests.rb', line 121

def merge_pull_request(owner, repo, number)
  put "/repos/#{owner}/#{repo}/pulls/#{number}/merge"
end

#pull_request(owner, repo, number) ⇒ Hash

Get a single pull request.

Examples:

GitHub.pull_request('caseyscarborough','github', 1)

Parameters:

  • owner (String)

    Repository owner.

  • repo (String)

    Repository name.

  • number (Integer)

    The pull request number.

Returns:

  • (Hash)

    The pull request information.

See Also:



29
30
31
# File 'lib/github_api_v3/client/pull_requests.rb', line 29

def pull_request(owner, repo, number)
  get "/repos/#{owner}/#{repo}/pulls/#{number}"
end

#pull_request_comment(owner, repo, number) ⇒ Hash

Get a single pull request comment.

Examples:

GitHub.pull_request_comment('caseyscarborough', 'github', 1242348)

Parameters:

  • owner (String)

    Repository owner.

  • repo (String)

    Repository name.

  • number (Integer)

    Comment number.

Returns:

  • (Hash)

    Comment information.

See Also:



155
156
157
# File 'lib/github_api_v3/client/pull_requests.rb', line 155

def pull_request_comment(owner, repo, number)
  get "/repos/#{owner}/#{repo}/pulls/comments/#{number}"
end

#pull_request_comments(owner, repo, number) ⇒ Array

List comments on a pull request.

Parameters:

  • owner (String)

    Repository owner.

  • repo (String)

    Repository name.

  • number (Integer)

    The pull request number.

Returns:

  • (Array)

    Array of comments as hashes.

See Also:



132
133
134
# File 'lib/github_api_v3/client/pull_requests.rb', line 132

def pull_request_comments(owner, repo, number)
  get "/repos/#{owner}/#{repo}/pulls/#{number}/comments"
end

#pull_request_commits(owner, repo, number) ⇒ Array

List commits on a pull request.

Parameters:

  • owner (String)

    Repository owner.

  • repo (String)

    Repository name.

  • number (Integer)

    The pull request number.

Returns:

  • (Array)

    Array of commits as hashes.

See Also:



86
87
88
# File 'lib/github_api_v3/client/pull_requests.rb', line 86

def pull_request_commits(owner, repo, number)
  get "/repos/#{owner}/#{repo}/pulls/#{number}/commits"
end

#pull_request_files(owner, repo, number) ⇒ Array

List pull requests files.

Parameters:

  • owner (String)

    Repository owner.

  • repo (String)

    Repository name.

  • number (Integer)

    The pull request number.

Returns:

  • (Array)

    Array of files as hashes.

See Also:



97
98
99
# File 'lib/github_api_v3/client/pull_requests.rb', line 97

def pull_request_files(owner, repo, number)
  get "/repos/#{owner}/#{repo}/pulls/#{number}/files"
end

#pull_request_merged?(owner, repo, number) ⇒ Boolean

Check if a pull request has been merged.

Parameters:

  • owner (String)

    Repository owner.

  • repo (String)

    Repository name.

  • number (Integer)

    The pull request number.

Returns:

  • (Boolean)

    True if it has been merged, false if not.

See Also:



108
109
110
# File 'lib/github_api_v3/client/pull_requests.rb', line 108

def pull_request_merged?(owner, repo, number)
  boolean_request :get, "/repos/#{owner}/#{repo}/pulls/#{number}/merge"
end

#pull_requests(owner, repo) ⇒ Array

List pull requests for a repository.

Examples:

GitHub.pull_requests('caseyscarborough','github')

Parameters:

  • owner (String)

    Repository owner.

  • repo (String)

    Repository name.

Returns:

  • (Array)

    Array of pull requests.

See Also:



16
17
18
# File 'lib/github_api_v3/client/pull_requests.rb', line 16

def pull_requests(owner, repo)
  get "/repos/#{owner}/#{repo}/pulls"
end

#repo_pull_request_comments(owner, repo) ⇒ Array

List comments in a repository.

Parameters:

  • owner (String)

    Repository owner.

  • repo (String)

    Repository name.

Returns:

  • (Array)

    Array of comments as hashes.

See Also:



142
143
144
# File 'lib/github_api_v3/client/pull_requests.rb', line 142

def repo_pull_request_comments(owner, repo)
  get "/repos/#{owner}/#{repo}/pulls/comments"
end

#update_pull_request(owner, repo, number, options = {}) ⇒ Hash

Update a pull request.

Requires authentication.

Parameters:

  • owner (String)

    Repository owner.

  • repo (String)

    Repository name.

  • number (Integer)

    The pull request number.

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

    Optional parameters..

Options Hash (options):

  • :title (String)

    The pull request title.

  • :body (String)
  • :state (String)

    The state of the pull request, open or closed.

Returns:

  • (Hash)

    The pull request information.

See Also:



75
76
77
# File 'lib/github_api_v3/client/pull_requests.rb', line 75

def update_pull_request(owner, repo, number, options={})
  patch "/repos/#{owner}/#{repo}/pulls/#{number}", body: options
end