class Github::Repos

def branch(user_name, repo_name, branch, params={})


github.repos.branch 'user-name', 'repo-name', 'branch-name'
github = Github.new

= Examples

Get branch
def branch(user_name, repo_name, branch, params={})
  normalize! params
  get_request("repos/#{user_name}/#{repo_name}/branches/#{branch}", params)
end

def branches(user_name, repo_name, params={})


repos.branches 'user-name', 'repo-name'
repos = Github::Repos.new

github.repos.branches 'user-name', 'repo-name'
github = Github.new

= Examples

List branches
def branches(user_name, repo_name, params={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless (user? && repo?)
  normalize! params
  response = get_request("/repos/#{user}/#{repo}/branches", params)
  return response unless block_given?
  response.each { |el| yield el }
end

def collaborators

Access to Repos::Collaborators API
def collaborators
  @collaborators ||= ApiFactory.new 'Repos::Collaborators'
end

def commits

Access to Repos::Commits API
def commits
  @commits ||= ApiFactory.new 'Repos::Commits'
end

def contents

Access to Repos::Contents API
def contents
  @contents ||= ApiFactory.new 'Repos::Contents'
end

def contributors(user_name, repo_name, params={})


github.repos.contributors 'user-name','repo-name' { |cont| ... }
github.repos.contributors 'user-name','repo-name'
github = Github.new

= Examples

:anon - Optional flag. Set to 1 or true to include anonymous contributors.
= Parameters

List contributors
def contributors(user_name, repo_name, params={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  normalize! params
  filter! ['anon'], params
  response = get_request("/repos/#{user}/#{repo}/contributors", params)
  return response unless block_given?
  response.each { |el| yield el }
end

def create(*args)


github.repos.create :name => 'repo-name', :org => 'organisation-name'
github = Github.new :oauth_token => '...'
Examples:

must be a member of this organisation
Create a new repository in this organisation. The authenticated user

"has_downloads": true
"has_wiki": true,
"has_issues": true,
"private": false,
"homepage": "https://github.com",
"description": "This is your first repo",
github.repos.create "name" => 'repo-name'
github = Github.new
= Examples

:team_id Optional number - The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization
:org Optional string - The organisation in which this repository will be created
:has_downloads Optional boolean - true to enable downloads for this repository
:has_wiki - Optional boolean - true to enable the wiki for this repository, false to disable it. Default is true
:has_issues - Optional boolean - true to enable issues for this repository, false to disable them
:private - Optional boolean - true to create a private repository, false to create a public one.
:homepage - Optional string
:description - Optional string
:name - Required string
= Parameters

Create a new repository for the autheticated user.
def create(*args)
  params = args.extract_options!
  normalize! params
  filter! VALID_REPO_OPTIONS + %w[ org ], params
  assert_required_keys(%w[ name ], params)
  # Requires authenticated user
  if (org = params.delete("org"))
    post_request("/orgs/#{org}/repos", DEFAULT_REPO_OPTIONS.merge(params))
  else
    post_request("/user/repos", DEFAULT_REPO_OPTIONS.merge(params))
  end
end

def downloads

Access to Repos::Downloads API
def downloads
  @downloads ||= ApiFactory.new 'Repos::Downloads'
end

def edit(user_name, repo_name, params={})


:public => true, :has_issues => true
:homepage => "https://github.com",
:description => 'This is your first repo',
:name => 'hello-world',
github.repos.edit 'user-name', 'repo-name',
github = Github.new

= Examples

* :has_downloads Optional boolean - true to enable downloads for this repository
* :has_wiki Optional boolean - true to enable the wiki for this repository, false to disable it. Default is true
* :has_issues Optional boolean - true to enable issues for this repository, false to disable them
:private - Optional boolean - false to create public reps, false to create a private one
* :homepage Optional string
* :description Optional string
* :name Required string
= Parameters

Edit a repository
def edit(user_name, repo_name, params={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  normalize! params
  filter! VALID_REPO_OPTIONS, params
  assert_required_keys(%w[ name ], params)
  patch_request("/repos/#{user}/#{repo}", DEFAULT_REPO_OPTIONS.merge(params))
end

def forks

Access to Repos::Forks API
def forks
  @forks ||= ApiFactory.new 'Repos::Forks'
end

def get(user_name, repo_name, params={})


github.repos.get 'user-name', 'repo-name'
github = Github.new
= Examples

Get a repository
def get(user_name, repo_name, params={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  normalize! params
  get_request("/repos/#{user}/#{repo}", params)
end

def hooks

Access to Repos::Hooks API
def hooks
  @hooks ||= ApiFactory.new 'Repos::Hooks'
end

def initialize(options = {})

Creates new Repositories API
def initialize(options = {})
  super(options)
end

def keys

Access to Repos::Keys API
def keys
  @keys ||= ApiFactory.new 'Repos::Keys'
end

def languages(user_name, repo_name, params={})


github.repos.languages 'user-name', 'repo-name' { |lang| ... }
github.repos.languages 'user-name', 'repo-name'
github = Github.new
= Examples

List languages
def languages(user_name, repo_name, params={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  normalize! params
  response = get_request("/repos/#{user}/#{repo}/languages", params)
  return response unless block_given?
  response.each { |el| yield el }
end

def list(*args)


github.repos.list :org => 'org-name', { |repo| ... }
github.repos.list :org => 'org-name'
github = Github.new
= Examples

List repositories for the specified organisation.

github.repos.list :user => 'user-name', { |repo| ... }
github.repos.list :user => 'user-name'
github = Github.new
= Examples

List public repositories for the specified user.

github.repos.list { |repo| ... }
github.repos.list
github = Github.new :oauth_token => '...'
= Examples

List repositories for the authenticated user
def list(*args)
  params = args.extract_options!
  normalize! params
  filter! %w[ org user type ], params
  response = if (user_name = params.delete("user"))
    get_request("/users/#{user_name}/repos", params)
  elsif (org_name = params.delete("org"))
    get_request("/orgs/#{org_name}/repos", params)
  else
    # For authenticated user
    get_request("/user/repos", params)
  end
  return response unless block_given?
  response.each { |el| yield el }
end

def merging

Access to Repos::Merging API
def merging
  @mergin ||= ApiFactory.new 'Repos::Merging'
end

def pubsubhubbub

Access to Repos::Watchin API
def pubsubhubbub
  @pubsubhubbub ||= ApiFactory.new 'Repos::PubSubHubbub'
end

def starring

Access to Repos::Starring API
def starring
  @starring ||= ApiFactory.new 'Repos::Starring'
end

def statuses

Access to Repos::Statuses API
def statuses
  @statuses ||= ApiFactory.new 'Repos::Statuses'
end

def tags(user_name, repo_name, params={})


github.repos.tags 'user-name', 'repo-name' { |tag| ... }
github.repos.tags 'user-name', 'repo-name'
github = Github.new
= Examples

List tags
def tags(user_name, repo_name, params={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  normalize! params
  response = get_request("/repos/#{user}/#{repo}/tags", params)
  return response unless block_given?
  response.each { |el| yield el }
end

def teams(user_name, repo_name, params={})


github.repos.teams 'user-name', 'repo-name' { |team| ... }
github.repos.teams 'user-name', 'repo-name'
github = Github.new
== Examples

List teams
def teams(user_name, repo_name, params={})
  _update_user_repo_params(user_name, repo_name)
  _validate_user_repo_params(user, repo) unless user? && repo?
  normalize! params
  response = get_request("/repos/#{user}/#{repo}/teams", params)
  return response unless block_given?
  response.each { |el| yield el }
end

def watching

Access to Repos::Watching API
def watching
  @watching ||= ApiFactory.new 'Repos::Watching'
end