class Github::Client::Repos

Constants

REQUIRED_REPO_OPTIONS
VALID_REPO_OPTIONS
VALID_REPO_TYPES

Public Instance Methods

all(*args)
Alias for: list
contribs(*args)
Alias for: contributors
contributors(*args) { |el| ... } click to toggle source

List contributors

@param [Hash] params @option params [Boolean] :anon

Optional flag. Set to 1 or true to include anonymous contributors.

@examples

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

@api public

# File lib/github_api/client/repos.rb, line 283
def contributors(*args)
  arguments(args, required: [:user, :repo]) do
    permit %w[ anon ]
  end

  response = get_request("/repos/#{arguments.user}/#{arguments.repo}/contributors", arguments.params)
  return response unless block_given?
  response.each { |el| yield el }
end
Also aliased as: list_contributors, contribs, list_contributors, contribs
create(*args) click to toggle source

Create a new repository for the autheticated user.

@param [Hash] params @option params [String] :name

Required string

@option params [String] :description

Optional string

@option params [String] :homepage

Optional string

@option params [Boolean] :private

Optional boolean - true to create a private  repository,
                   false to create a public one.

@option params [Boolean] :has_issues

Optional boolean - true to enable issues  for this repository,
                   false to disable them

@option params [Boolean] :has_wiki

Optional boolean - true to enable the wiki for this repository,
                   false to disable it. Default is true

@option params [Boolean] :has_downloads

Optional boolean - true to enable downloads for this repository

@option params [String] :org

Optional string - The organisation in which this
repository will be created

@option params [Numeric] :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

@option params [Boolean] :auto_init

Optional boolean - true to create an initial commit with
empty README. Default is false.

@option params [String] :gitignore_template

Optional string - Desired language or platform .gitignore
template to apply. Use the name of the template without
the extension. For example, “Haskell” Ignored if
auto_init parameter is not provided.

@example

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

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

@example

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

@example

# File lib/github_api/client/repos.rb, line 240
def create(*args)
  arguments(args) do
    assert_required %w[ name ]
  end
  params = arguments.params

  # Requires authenticated user
  if (org = params.delete('org') || org)
    post_request("/orgs/#{org}/repos", params)
  else
    post_request("/user/repos", params)
  end
end
delete(*args) click to toggle source

Delete a repository

Deleting a repository requires admin access. If OAuth is used, the delete_repo scope is required.

@example

github = Github.new oauth_token: '...'
github.repos.delete 'user-name', 'repo-name'

@api public

# File lib/github_api/client/repos.rb, line 264
def delete(*args)
  arguments(args, required: [:user, :repo])

  delete_request("/repos/#{arguments.user}/#{arguments.repo}", arguments.params)
end
Also aliased as: remove, remove
edit(*args) click to toggle source

Edit a repository

@param [Hash] params @option params [String] :name

Required string

@option params [String] :description

Optional string

@option params [String] :homepage

Optional string

@option params [Boolean] :private

Optional boolean, true to make this a private repository, false to make it a public one

@option params [Boolean] :has_issues

Optional boolean - true to enable issues for this repository,
false to disable them

@option params [Boolean] :has_wiki

Optional boolean - true to enable the wiki for this repository,
false to disable it. Default is true

@option params [Boolean] :has_downloads

Optional boolean - true to enable downloads for this repository

@option params [String] :default_branch

Optional string - Update the default branch for this repository.

@example

github = Github.new
github.repos.edit 'user-name', 'repo-name',
  name: 'hello-world',
  description: 'This is your first repo',
  homepage: "https://github.com",
  public: true, has_issues: true
# File lib/github_api/client/repos.rb, line 325
def edit(*args)
  arguments(args, required: [:user, :repo]) do
    permit VALID_REPO_OPTIONS
    assert_required %w[ name ]
  end

  patch_request("/repos/#{arguments.user}/#{arguments.repo}", arguments.params)
end
find(*args)
Alias for: get
find_by_id(*args)
Alias for: get_by_id
get(*args) click to toggle source

Get a repository

@example

github = Github.new
github.repos.get 'user-name', 'repo-name'
github.repos.get user: 'user-name', repo: 'repo-name'
github.repos(user: 'user-name', repo: 'repo-name').get
# File lib/github_api/client/repos.rb, line 164
def get(*args)
  arguments(args, required: [:user, :repo])

  get_request("/repos/#{arguments.user}/#{arguments.repo}", arguments.params)
end
Also aliased as: find
get_by_id(*args) click to toggle source

Get a repository

@example

github = Github.new
github.repos.get_by_id 'repo-id'
github.repos.get_by_id id: 'repo-id'
github.repos(id: 'repo-id').get_by_id
# File lib/github_api/client/repos.rb, line 179
def get_by_id(*args)
  arguments(args, required: [:id])

  get_request("/repositories/#{arguments.id}", arguments.params)
end
Also aliased as: find_by_id
languages(*args) { |el| ... } click to toggle source

List languages

@examples

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

@api public

# File lib/github_api/client/repos.rb, line 418
def languages(*args)
  arguments(args, required: [:user, :repo])

  response = get_request("/repos/#{arguments.user}/#{arguments.repo}/languages", arguments.params)
  return response unless block_given?
  response.each { |el| yield el }
end
Also aliased as: list_languages
list(*args) { |el| ... } click to toggle source

List repositories for the authenticated user

@example

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

List all repositories

This provides a dump of every repository, in the order that they were created.

@param [Hash] params @option params [Integer] :since

the integer ID of the last Repository that you've seen.

@example

github = Github.new
github.repos.list :every
github.repos.list :every { |repo| ... }

List public repositories for the specified user.

@example

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

List repositories for the specified organisation.

@example

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

@api public

# File lib/github_api/client/repos.rb, line 132
def list(*args)
  arguments(args) do
    permit %w[ user org type sort direction since ]
  end
  params = arguments.params
  unless params.symbolize_keys[:per_page]
    params.merge!(Pagination.per_page_as_param(current_options[:per_page]))
  end

  response = if (user_name = params.delete('user') || user)
    get_request("/users/#{user_name}/repos", params)
  elsif (org_name = params.delete('org') || org)
    get_request("/orgs/#{org_name}/repos", params)
  elsif args.map(&:to_s).include?('every')
    get_request('/repositories', params)
  else
    # For authenticated user
    get_request('/user/repos', params)
  end
  return response unless block_given?
  response.each { |el| yield el }
end
Also aliased as: all
list_contributors(*args)
Alias for: contributors
list_languages(*args)
Alias for: languages
list_tags(*args)
Alias for: tags
list_teams(*args)
Alias for: teams
remove(*args)
Alias for: delete
repo_tags(*args)
Alias for: tags
repo_teams(*args)
Alias for: teams
repository_tags(*args)
Alias for: tags
repository_teams(*args)
Alias for: teams
tags(*args) { |el| ... } click to toggle source

List tags

@example

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

@api public

# File lib/github_api/client/repos.rb, line 435
def tags(*args)
  arguments(args, required: [:user, :repo])

  response = get_request("/repos/#{arguments.user}/#{arguments.repo}/tags", arguments.params)
  return response unless block_given?
  response.each { |el| yield el }
end
Also aliased as: list_tags, repo_tags, repository_tags
teams(*args) { |el| ... } click to toggle source

List teams

@example

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

@example

github.repos(user: 'user-name, repo: 'repo-name').teams

@api public

# File lib/github_api/client/repos.rb, line 457
def teams(*args)
  arguments(args, required: [:user, :repo])

  response = get_request("/repos/#{arguments.user}/#{arguments.repo}/teams", arguments.params)
  return response unless block_given?
  response.each { |el| yield el }
end