Module: Octokit::Client::Repositories

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

Overview

Methods for the Repositories API

Instance Method Summary collapse

Instance Method Details

#add_collaborator(repo, collaborator, options = {}) ⇒ Boolean Also known as: add_collab

Add collaborator to repo

Requires authenticated client.

Examples:

@client.add_collaborator('octokit/octokit.rb', 'holman')
@client.add_collab('octokit/octokit.rb', 'holman')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

  • collaborator (String)

    Collaborator GitHub username to add.

Returns:

  • (Boolean)

    True if collaborator added, false otherwise.

See Also:



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

def add_collaborator(repo, collaborator, options = {})
  boolean_from_response :put, "repos/#{Repository.new repo}/collaborators/#{collaborator}", options
end

#add_deploy_key(repo, title, key, options = {}) ⇒ Sawyer::Resource

Add deploy key to a repo

Requires authenticated client.

Examples:

@client.add_deploy_key('octokit/octokit.rb', 'Staging server', 'ssh-rsa AAA...')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

  • title (String)

    Title reference for the deploy key.

  • key (String)

    Public key.

Returns:

  • (Sawyer::Resource)

    Hash representing newly added key.

See Also:



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

def add_deploy_key(repo, title, key, options = {})
  post "repos/#{Repository.new repo}/keys", options.merge(:title => title, :key => key)
end

#all_repositories(options = {}) ⇒ Array<Sawyer::Resource>

List all repositories

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

Parameters:

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

    Optional options

Options Hash (options):

  • :since (Integer)

    The integer ID of the last Repository that you’ve seen.

Returns:

  • (Array<Sawyer::Resource>)

    List of repositories.

See Also:



84
85
86
# File 'lib/octokit/client/repositories.rb', line 84

def all_repositories(options = {})
  paginate 'repositories', options
end

#branch(repo, branch, options = {}) ⇒ Sawyer::Resource Also known as: get_branch

Get a single branch from a repository

Examples:

Get branch ‘master` from octokit/octokit.rb

Octokit.branch("octokit/octokit.rb", "master")

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

  • branch (String)

    Branch name

Returns:

  • (Sawyer::Resource)

    The branch requested, if it exists

See Also:



432
433
434
# File 'lib/octokit/client/repositories.rb', line 432

def branch(repo, branch, options = {})
  get "repos/#{Repository.new repo}/branches/#{branch}", options
end

#branches(repo, options = {}) ⇒ Array<Sawyer::Resource>

List branches

Requires authenticated client for private repos.

Examples:

Octokit.branches('octokit/octokit.rb')
@client.branches('octokit/octokit.rb')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing branches.

See Also:



420
421
422
# File 'lib/octokit/client/repositories.rb', line 420

def branches(repo, options = {})
  paginate "repos/#{Repository.new repo}/branches", options
end

#check_assignee(repo, assignee, options = {}) ⇒ Boolean

Check to see if a particular user is an assignee for a repository.

Examples:

Octokit.check_assignee('octokit/octokit.rb', 'andrew')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

  • assignee (String)

    User login to check

Returns:

  • (Boolean)

    True if assignable on project, false otherwise.

See Also:



596
597
598
# File 'lib/octokit/client/repositories.rb', line 596

def check_assignee(repo, assignee, options = {})
  boolean_from_response :get, "repos/#{Repository.new repo}/assignees/#{assignee}", options
end

#collaborators(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: collabs

List collaborators

Requires authenticated client for private repos.

Examples:

Octokit.collaborators('octokit/octokit.rb')
Octokit.collabs('octokit/octokit.rb')
@client.collabs('octokit/octokit.rb')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing collaborating users.

See Also:



251
252
253
# File 'lib/octokit/client/repositories.rb', line 251

def collaborators(repo, options = {})
  paginate "repos/#{Repository.new repo}/collaborators", options
end

#contributors(repo, anon = nil, options = {}) ⇒ Array<Sawyer::Resource> Also known as: contribs

List contributors to a repo

Requires authenticated client for private repos.

Examples:

Octokit.contributors('octokit/octokit.rb', true)
Octokit.contribs('octokit/octokit.rb')
@client.contribs('octokit/octokit.rb')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

  • anon (Boolean) (defaults to: nil)

    Set true to include annonymous contributors.

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing users.

See Also:



323
324
325
326
# File 'lib/octokit/client/repositories.rb', line 323

def contributors(repo, anon = nil, options = {})
  options[:anon] = 1 if anon.to_s[/1|true/]
  paginate "repos/#{Repository.new repo}/contributors", options
end

#create_hook(repo, name, config, options = {}) ⇒ Sawyer::Resource

Create a hook

Requires authenticated client.

Examples:

@client.create_hook(
  'octokit/octokit.rb',
  'web',
  {
    :url => 'http://something.com/webhook',
    :content_type => 'json'
  },
  {
    :events => ['push', 'pull_request'],
    :active => true
  }
)

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

  • name (String)

    The name of the service that is being called. See Hooks for the possible names.

  • config (Hash)

    A Hash containing key/value pairs to provide settings for this hook. These settings vary between the services and are defined in the github-services repo.

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

    a customizable set of options

Options Hash (options):

  • :events (Array<String>) — default: '["push"]'

    Determines what events the hook is triggered for.

  • :active (Boolean)

    Determines whether the hook is actually triggered on pushes.

Returns:

  • (Sawyer::Resource)

    Hook info for the new hook

See Also:



495
496
497
498
# File 'lib/octokit/client/repositories.rb', line 495

def create_hook(repo, name, config, options = {})
  options = {:name => name, :config => config, :events => ["push"], :active => true}.merge(options)
  post "repos/#{Repository.new repo}/hooks", options
end

#create_repository(name, options = {}) ⇒ Sawyer::Resource Also known as: create_repo, create

Create a repository for a user or organization

Parameters:

  • name (String)

    Name of the new repo

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

    a customizable set of options

Options Hash (options):

  • :description (String)

    Description of the repo

  • :homepage (String)

    Home page of the repo

  • :private (String)

    ‘true` makes the repository private, and `false` makes it public.

  • :has_issues (String)

    ‘true` enables issues for this repo, `false` disables issues.

  • :has_wiki (String)

    ‘true` enables wiki for this repo, `false` disables wiki.

  • :has_downloads (String)

    ‘true` enables downloads for this repo, `false` disables downloads.

  • :organization (String)

    Short name for the org under which to create the repo.

  • :team_id (Integer)

    The id of the team that will be granted access to this repository. This is only valid when creating a repo in an organization.

  • :auto_init (Boolean)

    ‘true` to create an initial commit with empty README. Default is `false`.

  • :gitignore_template (String)

    Desired language or platform .gitignore template to apply. Ignored if auto_init parameter is not provided.

Returns:

  • (Sawyer::Resource)

    Repository info for the new repository

See Also:



150
151
152
153
154
155
156
157
158
159
# File 'lib/octokit/client/repositories.rb', line 150

def create_repository(name, options = {})
  organization = options.delete :organization
  options.merge! :name => name

  if organization.nil?
    post 'user/repos', options
  else
    post "orgs/#{organization}/repos", options
  end
end

#delete_repository(repo, options = {}) ⇒ Boolean Also known as: delete_repo

Delete repository

Note: If OAuth is used, ‘delete_repo’ scope is required

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

Returns:

  • (Boolean)

    ‘true` if repository was deleted

See Also:



170
171
172
# File 'lib/octokit/client/repositories.rb', line 170

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

#delete_subscription(repo, options = {}) ⇒ Boolean

Delete a repository subscription

Examples:

@client.delete_subscription("octokit/octokit.rb")

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

Returns:

  • (Boolean)

    True if subscription deleted, false otherwise.

See Also:



647
648
649
# File 'lib/octokit/client/repositories.rb', line 647

def delete_subscription(repo, options = {})
  boolean_from_response :delete, "repos/#{Repository.new repo}/subscription", options
end

#deploy_keys(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_deploy_keys

Get deploy keys on a repo

Requires authenticated client.

Examples:

@client.deploy_keys('octokit/octokit.rb')
@client.list_deploy_keys('octokit/octokit.rb')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing deploy keys.

See Also:



204
205
206
# File 'lib/octokit/client/repositories.rb', line 204

def deploy_keys(repo, options = {})
  paginate "repos/#{Repository.new repo}/keys", options
end

#edit_hook(repo, id, name, config, options = {}) ⇒ Sawyer::Resource

Edit a hook

Requires authenticated client.

Examples:

@client.edit_hook(
  'octokit/octokit.rb',
  'web',
  {
    :url => 'http://something.com/webhook',
    :content_type => 'json'
  },
  {
    :add_events => ['status'],
    :remove_events => ['pull_request'],
    :active => true
  }
)

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

  • id (Integer)

    Id of the hook being updated.

  • name (String)

    The name of the service that is being called. See Hooks for the possible names.

  • config (Hash)

    A Hash containing key/value pairs to provide settings for this hook. These settings vary between the services and are defined in the github-services repo.

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

    a customizable set of options

Options Hash (options):

  • :events (Array<String>) — default: '["push"]'

    Determines what events the hook is triggered for.

  • :add_events (Array<String>)

    Determines a list of events to be added to the list of events that the Hook triggers for.

  • :remove_events (Array<String>)

    Determines a list of events to be removed from the list of events that the Hook triggers for.

  • :active (Boolean)

    Determines whether the hook is actually triggered on pushes.

Returns:

  • (Sawyer::Resource)

    Hook info for the updated hook

See Also:



537
538
539
540
# File 'lib/octokit/client/repositories.rb', line 537

def edit_hook(repo, id, name, config, options = {})
  options = {:name => name, :config => config, :events => ["push"], :active => true}.merge(options)
  patch "repos/#{Repository.new repo}/hooks/#{id}", options
end

#edit_repository(repo, options = {}) ⇒ Sawyer::Resource Also known as: edit, update_repository, update

Edit a repository

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

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

    Repository information to update

Options Hash (options):

  • :name (String)

    Name of the repo

  • :description (String)

    Description of the repo

  • :homepage (String)

    Home page of the repo

  • :private (String)

    ‘true` makes the repository private, and `false` makes it public.

  • :has_issues (String)

    ‘true` enables issues for this repo, `false` disables issues.

  • :has_wiki (String)

    ‘true` enables wiki for this repo, `false` disables wiki.

  • :has_downloads (String)

    ‘true` enables downloads for this repo, `false` disables downloads.

  • :default_branch (String)

    Update the default branch for this repository.

Returns:

  • (Sawyer::Resource)

    Repository information

See Also:



45
46
47
48
49
# File 'lib/octokit/client/repositories.rb', line 45

def edit_repository(repo, options = {})
  repo = Repository.new(repo)
  options[:name] ||= repo.name
  patch "repos/#{repo}", options
end

#fork(repo, options = {}) ⇒ Sawyer::Resource

Fork a repository

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

Returns:

  • (Sawyer::Resource)

    Repository info for the new fork

See Also:



131
132
133
# File 'lib/octokit/client/repositories.rb', line 131

def fork(repo, options = {})
  post "repos/#{Repository.new repo}/forks", options
end

#forks(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: network

List forks

Requires authenticated client for private repos.

Examples:

Octokit.forks('octokit/octokit.rb')
Octokit.network('octokit/octokit.rb')
@client.forks('octokit/octokit.rb')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing repos.

See Also:



374
375
376
# File 'lib/octokit/client/repositories.rb', line 374

def forks(repo, options = {})
  paginate "repos/#{Repository.new repo}/forks", options
end

#hook(repo, id, options = {}) ⇒ Sawyer::Resource

Get single hook

Requires authenticated client.

Examples:

@client.hook('octokit/octokit.rb', 100000)

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

  • id (Integer)

    Id of the hook to get.

Returns:

  • (Sawyer::Resource)

    Hash representing hook.

See Also:



460
461
462
# File 'lib/octokit/client/repositories.rb', line 460

def hook(repo, id, options = {})
  get "repos/#{Repository.new repo}/hooks/#{id}", options
end

#hooks(repo, options = {}) ⇒ Array<Sawyer::Resource>

List repo hooks

Requires authenticated client.

Examples:

@client.hooks('octokit/octokit.rb')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing hooks.

See Also:



446
447
448
# File 'lib/octokit/client/repositories.rb', line 446

def hooks(repo, options = {})
  paginate "repos/#{Repository.new repo}/hooks", options
end

#languages(repo, options = {}) ⇒ Array<Sawyer::Resource>

List languages of code in the repo.

Requires authenticated client for private repos.

Examples:

Octokit.langauges('octokit/octokit.rb')
@client.languages('octokit/octokit.rb')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

Returns:

  • (Array<Sawyer::Resource>)

    Array of Hashes representing languages.

See Also:



390
391
392
# File 'lib/octokit/client/repositories.rb', line 390

def languages(repo, options = {})
  paginate "repos/#{Repository.new repo}/languages", options
end

#remove_collaborator(repo, collaborator, options = {}) ⇒ Boolean Also known as: remove_collab

Remove collaborator from repo.

Requires authenticated client.

Examples:

@client.remove_collaborator('octokit/octokit.rb', 'holman')
@client.remove_collab('octokit/octokit.rb', 'holman')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

  • collaborator (String)

    Collaborator GitHub username to remove.

Returns:

  • (Boolean)

    True if collaborator removed, false otherwise.

See Also:



285
286
287
# File 'lib/octokit/client/repositories.rb', line 285

def remove_collaborator(repo, collaborator, options = {})
  boolean_from_response :delete, "repos/#{Repository.new repo}/collaborators/#{collaborator}", options
end

#remove_deploy_key(repo, id, options = {}) ⇒ Boolean

Remove deploy key from a repo

Requires authenticated client.

Examples:

@client.remove_deploy_key('octokit/octokit.rb', 100000)

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

  • id (Integer)

    Id of the deploy key to remove.

Returns:

  • (Boolean)

    True if key removed, false otherwise.

See Also:



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

def remove_deploy_key(repo, id, options = {})
  boolean_from_response :delete, "repos/#{Repository.new repo}/keys/#{id}", options
end

#remove_hook(repo, id, options = {}) ⇒ Boolean

Delete hook

Requires authenticated client.

Examples:

@client.remove_hook('octokit/octokit.rb', 1000000)

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

  • id (Integer)

    Id of the hook to remove.

Returns:

  • (Boolean)

    True if hook removed, false otherwise.

See Also:



552
553
554
# File 'lib/octokit/client/repositories.rb', line 552

def remove_hook(repo, id, options = {})
  boolean_from_response :delete, "repos/#{Repository.new repo}/hooks/#{id}", options
end

#repositories(username = nil, options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_repositories, list_repos, repos

List repositories

If username is not supplied, repositories for the current authenticated user are returned

Parameters:

  • username (String) (defaults to: nil)

    Optional username for which to list repos

Returns:

  • (Array<Sawyer::Resource>)

    List of repositories

See Also:



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

def repositories(username=nil, options = {})
  if username.nil?
    paginate 'user/repos', options
  else
    paginate "users/#{username}/repos", options
  end
end

#repository(repo, options = {}) ⇒ Sawyer::Resource Also known as: repo

Get a single repository

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

Returns:

  • (Sawyer::Resource)

    Repository information

See Also:



26
27
28
# File 'lib/octokit/client/repositories.rb', line 26

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

#repository?(repo, options = {}) ⇒ Sawyer::Resource

Check if a repository exists

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

Returns:

  • (Sawyer::Resource)

    if a repository exists, false otherwise

See Also:



15
16
17
18
19
# File 'lib/octokit/client/repositories.rb', line 15

def repository?(repo, options = {})
  repository(repo, options)
rescue Octokit::NotFound
  false
end

#repository_assignees(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: repo_assignees

List users available for assigning to issues.

Requires authenticated client for private repos.

Examples:

Octokit.repository_assignees('octokit/octokit.rb')
Octokit.repo_assignees('octokit/octokit.rb')
@client.repository_assignees('octokit/octokit.rb')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing users.

See Also:



583
584
585
# File 'lib/octokit/client/repositories.rb', line 583

def repository_assignees(repo, options = {})
  paginate "repos/#{Repository.new repo}/assignees", options
end

#repository_teams(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: repo_teams, teams

List teams for a repo

Requires authenticated client that is an owner or collaborator of the repo.

Examples:

@client.repository_teams('octokit/pengwynn')
@client.repo_teams('octokit/pengwynn')
@client.teams('octokit/pengwynn')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing teams.

See Also:



303
304
305
# File 'lib/octokit/client/repositories.rb', line 303

def repository_teams(repo, options = {})
  paginate "repos/#{Repository.new repo}/teams", options
end

#set_private(repo, options = {}) ⇒ Sawyer::Resource

Hide a public repository

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

Returns:

  • (Sawyer::Resource)

    Updated repository info



179
180
181
182
# File 'lib/octokit/client/repositories.rb', line 179

def set_private(repo, options = {})
  # GitHub Api for setting private updated to use private attr, rather than public
  update_repository repo, options.merge({ :private => true })
end

#set_public(repo, options = {}) ⇒ Sawyer::Resource

Unhide a private repository

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

Returns:

  • (Sawyer::Resource)

    Updated repository info



188
189
190
191
# File 'lib/octokit/client/repositories.rb', line 188

def set_public(repo, options = {})
  # GitHub Api for setting private updated to use private attr, rather than public
  update_repository repo, options.merge({ :private => false })
end

#star(repo, options = {}) ⇒ Boolean

Star a repository

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

Returns:

  • (Boolean)

    ‘true` if successfully starred

See Also:



93
94
95
# File 'lib/octokit/client/repositories.rb', line 93

def star(repo, options = {})
  boolean_from_response :put, "user/starred/#{Repository.new repo}", options
end

#stargazers(repo, options = {}) ⇒ Array<Sawyer::Resource>

List stargazers of a repo

Requires authenticated client for private repos.

Examples:

Octokit.stargazers('octokit/octokit.rb')
@client.stargazers('octokit/octokit.rb')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing users.

See Also:



340
341
342
# File 'lib/octokit/client/repositories.rb', line 340

def stargazers(repo, options = {})
  paginate "repos/#{Repository.new repo}/stargazers", options
end

#subscribers(repo, options = {}) ⇒ Array<Sawyer::Resource>

List watchers subscribing to notifications for a repo

Examples:

@client.subscribers("octokit/octokit.rb")

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

Returns:

  • (Array<Sawyer::Resource>)

    Array of users watching.

See Also:



607
608
609
# File 'lib/octokit/client/repositories.rb', line 607

def subscribers(repo, options = {})
  paginate "repos/#{Repository.new repo}/subscribers", options
end

#subscription(repo, options = {}) ⇒ Sawyer::Resource

Get a repository subscription

Examples:

@client.subscription("octokit/octokit.rb")

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

Returns:

  • (Sawyer::Resource)

    Repository subscription.

See Also:



618
619
620
# File 'lib/octokit/client/repositories.rb', line 618

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

#tags(repo, options = {}) ⇒ Array<Sawyer::Resource>

List tags

Requires authenticated client for private repos.

Examples:

Octokit.tags('octokit/octokit.rb')
@client.tags('octokit/octokit.rb')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing tags.

See Also:



405
406
407
# File 'lib/octokit/client/repositories.rb', line 405

def tags(repo, options = {})
  paginate "repos/#{Repository.new repo}/tags", options
end

#test_hook(repo, id, options = {}) ⇒ Boolean

Test hook

Requires authenticated client.

Examples:

@client.test_hook('octokit/octokit.rb', 1000000)

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

  • id (Integer)

    Id of the hook to test.

Returns:

  • (Boolean)

    Success

See Also:



566
567
568
# File 'lib/octokit/client/repositories.rb', line 566

def test_hook(repo, id, options = {})
  boolean_from_response :post, "repos/#{Repository.new repo}/hooks/#{id}/tests", options
end

#unstar(repo, options = {}) ⇒ Boolean

Unstar a repository

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

Returns:

  • (Boolean)

    ‘true` if successfully unstarred

See Also:



102
103
104
# File 'lib/octokit/client/repositories.rb', line 102

def unstar(repo, options = {})
  boolean_from_response :delete, "user/starred/#{Repository.new repo}", options
end

#unwatch(repo, options = {}) ⇒ Boolean

Deprecated.

Use #unstar instead

Unwatch a repository

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

Returns:

  • (Boolean)

    ‘true` if successfully unwatched

See Also:



122
123
124
# File 'lib/octokit/client/repositories.rb', line 122

def unwatch(repo, options = {})
  boolean_from_response :delete, "user/watched/#{Repository.new repo}", options
end

#update_subscription(repo, options = {}) ⇒ Sawyer::Resource

Update repository subscription

Examples:

Subscribe to notifications for a repository

@client.update_subscription("octokit/octokit.rb", {subscribed: true})

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

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

Options Hash (options):

  • :subscribed (Boolean)

    Determines if notifications should be received from this repository.

  • :ignored (Boolean)

    Deterimines if all notifications should be blocked from this repository.

Returns:

  • (Sawyer::Resource)

    Updated repository subscription.

See Also:



635
636
637
# File 'lib/octokit/client/repositories.rb', line 635

def update_subscription(repo, options = {})
  put "repos/#{Repository.new repo}/subscription", options
end

#watch(repo, options = {}) ⇒ Boolean

Deprecated.

Use #star instead

Watch a repository

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository

Returns:

  • (Boolean)

    ‘true` if successfully watched

See Also:



112
113
114
# File 'lib/octokit/client/repositories.rb', line 112

def watch(repo, options = {})
  boolean_from_response :put, "user/watched/#{Repository.new repo}", options
end

#watchers(repo, options = {}) ⇒ Array<Sawyer::Resource>

Deprecated.

Use #stargazers instead

List watchers of repo.

Requires authenticated client for private repos.

Examples:

Octokit.watchers('octokit/octokit.rb')
@client.watchers('octokit/octokit.rb')

Parameters:

  • repo (String, Hash, Repository)

    A GitHub repository.

Returns:

  • (Array<Sawyer::Resource>)

    Array of hashes representing users.

See Also:



357
358
359
# File 'lib/octokit/client/repositories.rb', line 357

def watchers(repo, options = {})
  paginate "repos/#{Repository.new repo}/watchers", options
end