class Github::PullRequests
def comments(options={}, &block)
def comments(options={}, &block) @comments ||= ApiFactory.new('PullRequests::Comments', current_options.merge(options), &block) end
def commits(*args)
github.pull_requests.commits 'user-name', 'repo-name', 'number'
github = Github.new
= Examples
List commits on a pull request
def commits(*args) arguments(args, :required => [:user, :repo, :number]) response = get_request("/repos/#{user}/#{repo}/pulls/#{number}/commits", arguments.params) return response unless block_given? response.each { |el| yield el } end
def create(*args)
"base" => "master"
"head" => "octocat:new-feature",
"issue" => "5",
github.pull_requests.create 'user-name', 'repo-name',
alternatively
"base" => "master"
"head" => "octocat:new-feature",
"body" => "Please pull this in!",
"title" => "Amazing new feature",
github.pull_requests.create 'user-name', 'repo-name',
github = Github.new :oauth_token => '...'
= Examples
* issue - Required number - Issue number in this repository to turn into a Pull Request.
an Issue number instead of title and body.
You can also create a Pull Request from an existing Issue by passing
= Alternative Input
Typically you would namespace head with a user like this: username:branch.
note: head and base can be either a sha or a branch name.
* :head - Required string - The branch where your changes are implemented.
* :base - Required string - The branch you want your changes pulled into.
* :body - Optional string
* :title - Required string
= Inputs
Create a pull request
def create(*args) arguments(args, :required => [:user, :repo]) do sift VALID_REQUEST_PARAM_NAMES end post_request("/repos/#{user}/#{repo}/pulls", arguments.params) end
def files(*args)
github.pull_requests.files 'user-name', 'repo-name', 'number'
github = Github.new
= Examples
List pull requests files
def files(*args) arguments(args, :required => [:user, :repo, :number]) response = get_request("/repos/#{user}/#{repo}/pulls/#{number}/files", arguments.params) return response unless block_given? response.each { |el| yield el } end
def get(*args)
pulls.get 'user-name', 'repo-name', 'number'
pulls = Github::PullRequests.new
github.pull_requests.get 'user-name', 'repo-name', 'number'
github = Github.new
= Examples
Get a single pull request
def get(*args) arguments(args, :required => [:user, :repo, :number]) get_request("/repos/#{user}/#{repo}/pulls/#{number}", arguments.params) end
def list(*args)
pulls.pull_requests.list 'user-name', 'repo-name'
pulls = Github::PullRequests.new
github.pull_requests.list { |req| ... }
github.pull_requests.list
github = Github.new :user => 'user-name', :repo => 'repo-name'
= Examples
List pull requests
def list(*args) arguments(args, :required => [:user, :repo]) do sift VALID_REQUEST_PARAM_NAMES assert_values VALID_REQUEST_PARAM_VALUES end response = get_request("/repos/#{user}/#{repo}/pulls", arguments.params) return response unless block_given? response.each { |el| yield el } end
def merge(*args)
github.pull_requests.merge 'user-name', 'repo-name', 'number'
github = Github.new
= Examples
The message that will be used for the merge commit
:commit_message - Optional string -
= Inputs
Merge a pull request(Merge Button)
def merge(*args) arguments(args, :required => [:user, :repo, :number]) do sift VALID_REQUEST_PARAM_NAMES end put_request("/repos/#{user}/#{repo}/pulls/#{number}/merge", arguments.params) end
def merged?(*args)
github.pull_requests.merged? 'user-name', 'repo-name', 'number'
github = Github.new
= Examples
Check if pull request has been merged
def merged?(*args) arguments(args, :required => [:user, :repo, :number]) get_request("/repos/#{user}/#{repo}/pulls/#{number}/merge", arguments.params) true rescue Github::Error::NotFound false end
def update(*args)
"state" => "open",
"body" => "Update body",
"title" => "Amazing new title",
github.pull_requests.update 'user-name', 'repo-name', 'number'
github = Github.new :oauth_token => '...'
= Examples
* :state - Optional string - State of this Pull Request. Valid values are open and closed.
* :body - Optional string
* :title - Optional string
= Inputs
Update a pull request
def update(*args) arguments(args, :required => [:user, :repo, :number]) do sift VALID_REQUEST_PARAM_NAMES assert_values VALID_REQUEST_PARAM_VALUES end patch_request("/repos/#{user}/#{repo}/pulls/#{number}", arguments.params) end