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
-
#add_collaborator(repo, collaborator, options = {}) ⇒ Boolean
(also: #add_collab)
Add collaborator to repo.
-
#add_deploy_key(repo, title, key, options = {}) ⇒ Sawyer::Resource
Add deploy key to a repo.
-
#all_repositories(options = {}) ⇒ Array<Sawyer::Resource>
List all repositories.
-
#branch(repo, branch, options = {}) ⇒ Sawyer::Resource
(also: #get_branch)
Get a single branch from a repository.
-
#branches(repo, options = {}) ⇒ Array<Sawyer::Resource>
List branches.
-
#check_assignee(repo, assignee, options = {}) ⇒ Boolean
Check to see if a particular user is an assignee for a repository.
-
#collaborator?(repo, collaborator, options = {}) ⇒ Boolean
Checks if a user is a collaborator for a repo.
-
#collaborators(repo, options = {}) ⇒ Array<Sawyer::Resource>
(also: #collabs)
List collaborators.
-
#contributors(repo, anon = nil, options = {}) ⇒ Array<Sawyer::Resource>
(also: #contribs)
List contributors to a repo.
-
#create_hook(repo, name, config, options = {}) ⇒ Sawyer::Resource
Create a hook.
-
#create_repository(name, options = {}) ⇒ Sawyer::Resource
(also: #create_repo, #create)
Create a repository for a user or organization.
-
#delete_repository(repo, options = {}) ⇒ Boolean
(also: #delete_repo)
Delete repository.
-
#delete_subscription(repo, options = {}) ⇒ Boolean
Delete a repository subscription.
-
#deploy_key(repo, id, options = {}) ⇒ Sawyer::Resource
Get a single deploy key for a repo.
-
#deploy_keys(repo, options = {}) ⇒ Array<Sawyer::Resource>
(also: #list_deploy_keys)
Get deploy keys on a repo.
-
#edit_deploy_key(repo, id, options) ⇒ Sawyer::Resource
(also: #update_deploy_key)
deprecated
Deprecated.
This method is no longer supported in the API
-
#edit_hook(repo, id, name, config, options = {}) ⇒ Sawyer::Resource
Edit a hook.
-
#edit_repository(repo, options = {}) ⇒ Sawyer::Resource
(also: #edit, #update_repository, #update)
Edit a repository.
-
#fork(repo, options = {}) ⇒ Sawyer::Resource
Fork a repository.
-
#forks(repo, options = {}) ⇒ Array<Sawyer::Resource>
(also: #network)
List forks.
-
#hook(repo, id, options = {}) ⇒ Sawyer::Resource
Get single hook.
-
#hooks(repo, options = {}) ⇒ Array<Sawyer::Resource>
List repo hooks.
-
#languages(repo, options = {}) ⇒ Array<Sawyer::Resource>
List languages of code in the repo.
-
#remove_collaborator(repo, collaborator, options = {}) ⇒ Boolean
(also: #remove_collab)
Remove collaborator from repo.
-
#remove_deploy_key(repo, id, options = {}) ⇒ Boolean
Remove deploy key from a repo.
-
#remove_hook(repo, id, options = {}) ⇒ Boolean
Delete hook.
-
#repositories(user = nil, options = {}) ⇒ Array<Sawyer::Resource>
(also: #list_repositories, #list_repos, #repos)
List user repositories.
-
#repository(repo, options = {}) ⇒ Sawyer::Resource
(also: #repo)
Get a single repository.
-
#repository?(repo, options = {}) ⇒ Sawyer::Resource
Check if a repository exists.
-
#repository_assignees(repo, options = {}) ⇒ Array<Sawyer::Resource>
(also: #repo_assignees)
List users available for assigning to issues.
-
#repository_teams(repo, options = {}) ⇒ Array<Sawyer::Resource>
(also: #repo_teams, #teams)
List teams for a repo.
-
#set_private(repo, options = {}) ⇒ Sawyer::Resource
Hide a public repository.
-
#set_public(repo, options = {}) ⇒ Sawyer::Resource
Unhide a private repository.
-
#star(repo, options = {}) ⇒ Boolean
Star a repository.
-
#stargazers(repo, options = {}) ⇒ Array<Sawyer::Resource>
List stargazers of a repo.
-
#subscribers(repo, options = {}) ⇒ Array<Sawyer::Resource>
List watchers subscribing to notifications for a repo.
-
#subscription(repo, options = {}) ⇒ Sawyer::Resource
Get a repository subscription.
-
#tags(repo, options = {}) ⇒ Array<Sawyer::Resource>
List tags.
-
#test_hook(repo, id, options = {}) ⇒ Boolean
Test hook.
-
#unstar(repo, options = {}) ⇒ Boolean
Unstar a repository.
-
#unwatch(repo, options = {}) ⇒ Boolean
deprecated
Deprecated.
Use #unstar instead
-
#update_subscription(repo, options = {}) ⇒ Sawyer::Resource
Update repository subscription.
-
#watch(repo, options = {}) ⇒ Boolean
deprecated
Deprecated.
Use #star instead
-
#watchers(repo, options = {}) ⇒ Array<Sawyer::Resource>
deprecated
Deprecated.
Use #stargazers instead
Instance Method Details
#add_collaborator(repo, collaborator, options = {}) ⇒ Boolean Also known as: add_collab
Add collaborator to repo
Requires authenticated client.
301 302 303 |
# File 'lib/octokit/client/repositories.rb', line 301 def add_collaborator(repo, collaborator, = {}) boolean_from_response :put, "#{Repository.path repo}/collaborators/#{collaborator}", end |
#add_deploy_key(repo, title, key, options = {}) ⇒ Sawyer::Resource
Add deploy key to a repo
Requires authenticated client.
233 234 235 |
# File 'lib/octokit/client/repositories.rb', line 233 def add_deploy_key(repo, title, key, = {}) post "#{Repository.path repo}/keys", .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.
85 86 87 |
# File 'lib/octokit/client/repositories.rb', line 85 def all_repositories( = {}) paginate 'repositories', end |
#branch(repo, branch, options = {}) ⇒ Sawyer::Resource Also known as: get_branch
Get a single branch from a repository
479 480 481 |
# File 'lib/octokit/client/repositories.rb', line 479 def branch(repo, branch, = {}) get "#{Repository.path repo}/branches/#{branch}", end |
#branches(repo, options = {}) ⇒ Array<Sawyer::Resource>
List branches
Requires authenticated client for private repos.
467 468 469 |
# File 'lib/octokit/client/repositories.rb', line 467 def branches(repo, = {}) paginate "#{Repository.path repo}/branches", end |
#check_assignee(repo, assignee, options = {}) ⇒ Boolean
Check to see if a particular user is an assignee for a repository.
644 645 646 |
# File 'lib/octokit/client/repositories.rb', line 644 def check_assignee(repo, assignee, = {}) boolean_from_response :get, "#{Repository.path repo}/assignees/#{assignee}", end |
#collaborator?(repo, collaborator, options = {}) ⇒ Boolean
Checks if a user is a collaborator for a repo.
Requires authenticated client.
333 334 335 |
# File 'lib/octokit/client/repositories.rb', line 333 def collaborator?(repo, collaborator, ={}) boolean_from_response :get, "#{Repository.path repo}/collaborators/#{collaborator}", end |
#collaborators(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: collabs
List collaborators
Requires authenticated client for private repos.
284 285 286 |
# File 'lib/octokit/client/repositories.rb', line 284 def collaborators(repo, = {}) paginate "#{Repository.path repo}/collaborators", end |
#contributors(repo, anon = nil, options = {}) ⇒ Array<Sawyer::Resource> Also known as: contribs
List contributors to a repo
Requires authenticated client for private repos.
370 371 372 373 |
# File 'lib/octokit/client/repositories.rb', line 370 def contributors(repo, anon = nil, = {}) [:anon] = 1 if anon.to_s[/1|true/] paginate "#{Repository.path repo}/contributors", end |
#create_hook(repo, name, config, options = {}) ⇒ Sawyer::Resource
Create a hook
Requires authenticated client.
542 543 544 545 |
# File 'lib/octokit/client/repositories.rb', line 542 def create_hook(repo, name, config, = {}) = {:name => name, :config => config, :events => ["push"], :active => true}.merge() post "#{Repository.path repo}/hooks", end |
#create_repository(name, options = {}) ⇒ Sawyer::Resource Also known as: create_repo, create
Create a repository for a user or organization
151 152 153 154 155 156 157 158 159 160 |
# File 'lib/octokit/client/repositories.rb', line 151 def create_repository(name, = {}) organization = .delete :organization .merge! :name => name if organization.nil? post 'user/repos', else post "orgs/#{organization}/repos", end end |
#delete_repository(repo, options = {}) ⇒ Boolean Also known as: delete_repo
Delete repository
Note: If OAuth is used, ‘delete_repo’ scope is required
171 172 173 |
# File 'lib/octokit/client/repositories.rb', line 171 def delete_repository(repo, = {}) boolean_from_response :delete, Repository.path(repo), end |
#delete_subscription(repo, options = {}) ⇒ Boolean
Delete a repository subscription
695 696 697 |
# File 'lib/octokit/client/repositories.rb', line 695 def delete_subscription(repo, = {}) boolean_from_response :delete, "#{Repository.path repo}/subscription", end |
#deploy_key(repo, id, options = {}) ⇒ Sawyer::Resource
Get a single deploy key for a repo
218 219 220 |
# File 'lib/octokit/client/repositories.rb', line 218 def deploy_key(repo, id, ={}) get "#{Repository.path repo}/keys/#{id}", end |
#deploy_keys(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_deploy_keys
Get deploy keys on a repo
Requires authenticated client.
205 206 207 |
# File 'lib/octokit/client/repositories.rb', line 205 def deploy_keys(repo, = {}) paginate "#{Repository.path repo}/keys", end |
#edit_deploy_key(repo, id, options) ⇒ Sawyer::Resource Also known as: update_deploy_key
This method is no longer supported in the API
Edit a deploy key
252 253 254 |
# File 'lib/octokit/client/repositories.rb', line 252 def edit_deploy_key(repo, id, ) patch "#{Repository.path repo}/keys/#{id}", end |
#edit_hook(repo, id, name, config, options = {}) ⇒ Sawyer::Resource
Edit a hook
Requires authenticated client.
585 586 587 588 |
# File 'lib/octokit/client/repositories.rb', line 585 def edit_hook(repo, id, name, config, = {}) = {:name => name, :config => config, :events => ["push"], :active => true}.merge() patch "#{Repository.path repo}/hooks/#{id}", end |
#edit_repository(repo, options = {}) ⇒ Sawyer::Resource Also known as: edit, update_repository, update
Edit a repository
44 45 46 47 48 |
# File 'lib/octokit/client/repositories.rb', line 44 def edit_repository(repo, = {}) repo = Repository.new(repo) [:name] ||= repo.name patch "repos/#{repo}", end |
#fork(repo, options = {}) ⇒ Sawyer::Resource
Fork a repository
132 133 134 |
# File 'lib/octokit/client/repositories.rb', line 132 def fork(repo, = {}) post "#{Repository.path repo}/forks", end |
#forks(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: network
List forks
Requires authenticated client for private repos.
421 422 423 |
# File 'lib/octokit/client/repositories.rb', line 421 def forks(repo, = {}) paginate "#{Repository.path repo}/forks", end |
#hook(repo, id, options = {}) ⇒ Sawyer::Resource
Get single hook
Requires authenticated client.
507 508 509 |
# File 'lib/octokit/client/repositories.rb', line 507 def hook(repo, id, = {}) get "#{Repository.path repo}/hooks/#{id}", end |
#hooks(repo, options = {}) ⇒ Array<Sawyer::Resource>
List repo hooks
Requires authenticated client.
493 494 495 |
# File 'lib/octokit/client/repositories.rb', line 493 def hooks(repo, = {}) paginate "#{Repository.path repo}/hooks", end |
#languages(repo, options = {}) ⇒ Array<Sawyer::Resource>
List languages of code in the repo.
Requires authenticated client for private repos.
437 438 439 |
# File 'lib/octokit/client/repositories.rb', line 437 def languages(repo, = {}) paginate "#{Repository.path repo}/languages", end |
#remove_collaborator(repo, collaborator, options = {}) ⇒ Boolean Also known as: remove_collab
Remove collaborator from repo.
Requires authenticated client.
318 319 320 |
# File 'lib/octokit/client/repositories.rb', line 318 def remove_collaborator(repo, collaborator, = {}) boolean_from_response :delete, "#{Repository.path repo}/collaborators/#{collaborator}", end |
#remove_deploy_key(repo, id, options = {}) ⇒ Boolean
Remove deploy key from a repo
Requires authenticated client.
267 268 269 |
# File 'lib/octokit/client/repositories.rb', line 267 def remove_deploy_key(repo, id, = {}) boolean_from_response :delete, "#{Repository.path repo}/keys/#{id}", end |
#remove_hook(repo, id, options = {}) ⇒ Boolean
Delete hook
Requires authenticated client.
600 601 602 |
# File 'lib/octokit/client/repositories.rb', line 600 def remove_hook(repo, id, = {}) boolean_from_response :delete, "#{Repository.path repo}/hooks/#{id}", end |
#repositories(user = nil, options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_repositories, list_repos, repos
If the user provided is a GitHub organization, only the organization’s public repositories will be listed. For retrieving organization repositories the Organizations#organization_repositories method should be used instead.
List user repositories
If user is not supplied, repositories for the current
authenticated user are returned.
67 68 69 |
# File 'lib/octokit/client/repositories.rb', line 67 def repositories(user=nil, = {}) paginate "#{User.path user}/repos", end |
#repository(repo, options = {}) ⇒ Sawyer::Resource Also known as: repo
Get a single repository
25 26 27 |
# File 'lib/octokit/client/repositories.rb', line 25 def repository(repo, = {}) get Repository.path(repo), end |
#repository?(repo, options = {}) ⇒ Sawyer::Resource
Check if a repository exists
14 15 16 17 18 |
# File 'lib/octokit/client/repositories.rb', line 14 def repository?(repo, = {}) !!repository(repo, ) 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.
631 632 633 |
# File 'lib/octokit/client/repositories.rb', line 631 def repository_assignees(repo, = {}) paginate "#{Repository.path repo}/assignees", 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.
350 351 352 |
# File 'lib/octokit/client/repositories.rb', line 350 def repository_teams(repo, = {}) paginate "#{Repository.path repo}/teams", end |
#set_private(repo, options = {}) ⇒ Sawyer::Resource
Hide a public repository
180 181 182 183 |
# File 'lib/octokit/client/repositories.rb', line 180 def set_private(repo, = {}) # GitHub Api for setting private updated to use private attr, rather than public update_repository repo, .merge({ :private => true }) end |
#set_public(repo, options = {}) ⇒ Sawyer::Resource
Unhide a private repository
189 190 191 192 |
# File 'lib/octokit/client/repositories.rb', line 189 def set_public(repo, = {}) # GitHub Api for setting private updated to use private attr, rather than public update_repository repo, .merge({ :private => false }) end |
#star(repo, options = {}) ⇒ Boolean
Star a repository
94 95 96 |
# File 'lib/octokit/client/repositories.rb', line 94 def star(repo, = {}) boolean_from_response :put, "user/starred/#{Repository.new(repo)}", end |
#stargazers(repo, options = {}) ⇒ Array<Sawyer::Resource>
List stargazers of a repo
Requires authenticated client for private repos.
387 388 389 |
# File 'lib/octokit/client/repositories.rb', line 387 def stargazers(repo, = {}) paginate "#{Repository.path repo}/stargazers", end |
#subscribers(repo, options = {}) ⇒ Array<Sawyer::Resource>
List watchers subscribing to notifications for a repo
655 656 657 |
# File 'lib/octokit/client/repositories.rb', line 655 def subscribers(repo, = {}) paginate "#{Repository.path repo}/subscribers", end |
#subscription(repo, options = {}) ⇒ Sawyer::Resource
Get a repository subscription
666 667 668 |
# File 'lib/octokit/client/repositories.rb', line 666 def subscription(repo, = {}) get "#{Repository.path repo}/subscription", end |
#tags(repo, options = {}) ⇒ Array<Sawyer::Resource>
List tags
Requires authenticated client for private repos.
452 453 454 |
# File 'lib/octokit/client/repositories.rb', line 452 def (repo, = {}) paginate "#{Repository.path repo}/tags", end |
#test_hook(repo, id, options = {}) ⇒ Boolean
Test hook
Requires authenticated client.
614 615 616 |
# File 'lib/octokit/client/repositories.rb', line 614 def test_hook(repo, id, = {}) boolean_from_response :post, "#{Repository.path repo}/hooks/#{id}/tests", end |
#unstar(repo, options = {}) ⇒ Boolean
Unstar a repository
103 104 105 |
# File 'lib/octokit/client/repositories.rb', line 103 def unstar(repo, = {}) boolean_from_response :delete, "user/starred/#{Repository.new(repo)}", end |
#unwatch(repo, options = {}) ⇒ Boolean
Use #unstar instead
Unwatch a repository
123 124 125 |
# File 'lib/octokit/client/repositories.rb', line 123 def unwatch(repo, = {}) boolean_from_response :delete, "user/watched/#{Repository.new(repo)}", end |
#update_subscription(repo, options = {}) ⇒ Sawyer::Resource
Update repository subscription
683 684 685 |
# File 'lib/octokit/client/repositories.rb', line 683 def update_subscription(repo, = {}) put "#{Repository.path repo}/subscription", end |
#watch(repo, options = {}) ⇒ Boolean
Use #star instead
Watch a repository
113 114 115 |
# File 'lib/octokit/client/repositories.rb', line 113 def watch(repo, = {}) boolean_from_response :put, "user/watched/#{Repository.new(repo)}", end |
#watchers(repo, options = {}) ⇒ Array<Sawyer::Resource>
Use #stargazers instead
List watchers of repo.
Requires authenticated client for private repos.
404 405 406 |
# File 'lib/octokit/client/repositories.rb', line 404 def watchers(repo, = {}) paginate "#{Repository.path repo}/watchers", end |