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.
-
#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_keys(repo, options = {}) ⇒ Array<Sawyer::Resource>
(also: #list_deploy_keys)
Get deploy keys on a repo.
-
#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(username = nil, options = {}) ⇒ Array<Sawyer::Resource>
(also: #list_repositories, #list_repos, #repos)
List 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.
268 269 270 |
# File 'lib/octokit/client/repositories.rb', line 268 def add_collaborator(repo, collaborator, = {}) boolean_from_response :put, "repos/#{Repository.new repo}/collaborators/#{collaborator}", end |
#add_deploy_key(repo, title, key, options = {}) ⇒ Sawyer::Resource
Add deploy key to a repo
Requires authenticated client.
220 221 222 |
# File 'lib/octokit/client/repositories.rb', line 220 def add_deploy_key(repo, title, key, = {}) post "repos/#{Repository.new 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.
84 85 86 |
# File 'lib/octokit/client/repositories.rb', line 84 def all_repositories( = {}) paginate 'repositories', end |
#branch(repo, branch, options = {}) ⇒ Sawyer::Resource Also known as: get_branch
Get a single branch from a repository
432 433 434 |
# File 'lib/octokit/client/repositories.rb', line 432 def branch(repo, branch, = {}) get "repos/#{Repository.new repo}/branches/#{branch}", end |
#branches(repo, options = {}) ⇒ Array<Sawyer::Resource>
List branches
Requires authenticated client for private repos.
420 421 422 |
# File 'lib/octokit/client/repositories.rb', line 420 def branches(repo, = {}) paginate "repos/#{Repository.new repo}/branches", end |
#check_assignee(repo, assignee, options = {}) ⇒ Boolean
Check to see if a particular user is an assignee for a repository.
596 597 598 |
# File 'lib/octokit/client/repositories.rb', line 596 def check_assignee(repo, assignee, = {}) boolean_from_response :get, "repos/#{Repository.new repo}/assignees/#{assignee}", end |
#collaborators(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: collabs
List collaborators
Requires authenticated client for private repos.
251 252 253 |
# File 'lib/octokit/client/repositories.rb', line 251 def collaborators(repo, = {}) paginate "repos/#{Repository.new 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.
323 324 325 326 |
# File 'lib/octokit/client/repositories.rb', line 323 def contributors(repo, anon = nil, = {}) [:anon] = 1 if anon.to_s[/1|true/] paginate "repos/#{Repository.new repo}/contributors", end |
#create_hook(repo, name, config, options = {}) ⇒ Sawyer::Resource
Create a hook
Requires authenticated client.
495 496 497 498 |
# File 'lib/octokit/client/repositories.rb', line 495 def create_hook(repo, name, config, = {}) = {:name => name, :config => config, :events => ["push"], :active => true}.merge() post "repos/#{Repository.new repo}/hooks", end |
#create_repository(name, options = {}) ⇒ Sawyer::Resource Also known as: create_repo, create
Create a repository for a user or organization
150 151 152 153 154 155 156 157 158 159 |
# File 'lib/octokit/client/repositories.rb', line 150 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
170 171 172 |
# File 'lib/octokit/client/repositories.rb', line 170 def delete_repository(repo, = {}) boolean_from_response :delete, "repos/#{Repository.new repo}", end |
#delete_subscription(repo, options = {}) ⇒ Boolean
Delete a repository subscription
647 648 649 |
# File 'lib/octokit/client/repositories.rb', line 647 def delete_subscription(repo, = {}) boolean_from_response :delete, "repos/#{Repository.new repo}/subscription", end |
#deploy_keys(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: list_deploy_keys
Get deploy keys on a repo
Requires authenticated client.
204 205 206 |
# File 'lib/octokit/client/repositories.rb', line 204 def deploy_keys(repo, = {}) paginate "repos/#{Repository.new repo}/keys", end |
#edit_hook(repo, id, name, config, options = {}) ⇒ Sawyer::Resource
Edit a hook
Requires authenticated client.
537 538 539 540 |
# File 'lib/octokit/client/repositories.rb', line 537 def edit_hook(repo, id, name, config, = {}) = {:name => name, :config => config, :events => ["push"], :active => true}.merge() patch "repos/#{Repository.new repo}/hooks/#{id}", end |
#edit_repository(repo, options = {}) ⇒ Sawyer::Resource Also known as: edit, update_repository, update
Edit a repository
45 46 47 48 49 |
# File 'lib/octokit/client/repositories.rb', line 45 def edit_repository(repo, = {}) repo = Repository.new(repo) [:name] ||= repo.name patch "repos/#{repo}", end |
#fork(repo, options = {}) ⇒ Sawyer::Resource
Fork a repository
131 132 133 |
# File 'lib/octokit/client/repositories.rb', line 131 def fork(repo, = {}) post "repos/#{Repository.new repo}/forks", end |
#forks(repo, options = {}) ⇒ Array<Sawyer::Resource> Also known as: network
List forks
Requires authenticated client for private repos.
374 375 376 |
# File 'lib/octokit/client/repositories.rb', line 374 def forks(repo, = {}) paginate "repos/#{Repository.new repo}/forks", end |
#hook(repo, id, options = {}) ⇒ Sawyer::Resource
Get single hook
Requires authenticated client.
460 461 462 |
# File 'lib/octokit/client/repositories.rb', line 460 def hook(repo, id, = {}) get "repos/#{Repository.new repo}/hooks/#{id}", end |
#hooks(repo, options = {}) ⇒ Array<Sawyer::Resource>
List repo hooks
Requires authenticated client.
446 447 448 |
# File 'lib/octokit/client/repositories.rb', line 446 def hooks(repo, = {}) paginate "repos/#{Repository.new repo}/hooks", end |
#languages(repo, options = {}) ⇒ Array<Sawyer::Resource>
List languages of code in the repo.
Requires authenticated client for private repos.
390 391 392 |
# File 'lib/octokit/client/repositories.rb', line 390 def languages(repo, = {}) paginate "repos/#{Repository.new repo}/languages", end |
#remove_collaborator(repo, collaborator, options = {}) ⇒ Boolean Also known as: remove_collab
Remove collaborator from repo.
Requires authenticated client.
285 286 287 |
# File 'lib/octokit/client/repositories.rb', line 285 def remove_collaborator(repo, collaborator, = {}) boolean_from_response :delete, "repos/#{Repository.new repo}/collaborators/#{collaborator}", end |
#remove_deploy_key(repo, id, options = {}) ⇒ Boolean
Remove deploy key from a repo
Requires authenticated client.
234 235 236 |
# File 'lib/octokit/client/repositories.rb', line 234 def remove_deploy_key(repo, id, = {}) boolean_from_response :delete, "repos/#{Repository.new repo}/keys/#{id}", end |
#remove_hook(repo, id, options = {}) ⇒ Boolean
Delete hook
Requires authenticated client.
552 553 554 |
# File 'lib/octokit/client/repositories.rb', line 552 def remove_hook(repo, id, = {}) boolean_from_response :delete, "repos/#{Repository.new repo}/hooks/#{id}", 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
62 63 64 65 66 67 68 |
# File 'lib/octokit/client/repositories.rb', line 62 def repositories(username=nil, = {}) if username.nil? paginate 'user/repos', else paginate "users/#{username}/repos", end end |
#repository(repo, options = {}) ⇒ Sawyer::Resource Also known as: repo
Get a single repository
26 27 28 |
# File 'lib/octokit/client/repositories.rb', line 26 def repository(repo, = {}) get "repos/#{Repository.new repo}", end |
#repository?(repo, options = {}) ⇒ Sawyer::Resource
Check if a repository exists
15 16 17 18 19 |
# File 'lib/octokit/client/repositories.rb', line 15 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.
583 584 585 |
# File 'lib/octokit/client/repositories.rb', line 583 def repository_assignees(repo, = {}) paginate "repos/#{Repository.new 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.
303 304 305 |
# File 'lib/octokit/client/repositories.rb', line 303 def repository_teams(repo, = {}) paginate "repos/#{Repository.new repo}/teams", end |
#set_private(repo, options = {}) ⇒ Sawyer::Resource
Hide a public repository
179 180 181 182 |
# File 'lib/octokit/client/repositories.rb', line 179 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
188 189 190 191 |
# File 'lib/octokit/client/repositories.rb', line 188 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
93 94 95 |
# File 'lib/octokit/client/repositories.rb', line 93 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.
340 341 342 |
# File 'lib/octokit/client/repositories.rb', line 340 def stargazers(repo, = {}) paginate "repos/#{Repository.new repo}/stargazers", end |
#subscribers(repo, options = {}) ⇒ Array<Sawyer::Resource>
List watchers subscribing to notifications for a repo
607 608 609 |
# File 'lib/octokit/client/repositories.rb', line 607 def subscribers(repo, = {}) paginate "repos/#{Repository.new repo}/subscribers", end |
#subscription(repo, options = {}) ⇒ Sawyer::Resource
Get a repository subscription
618 619 620 |
# File 'lib/octokit/client/repositories.rb', line 618 def subscription(repo, = {}) get "repos/#{Repository.new repo}/subscription", end |
#tags(repo, options = {}) ⇒ Array<Sawyer::Resource>
List tags
Requires authenticated client for private repos.
405 406 407 |
# File 'lib/octokit/client/repositories.rb', line 405 def (repo, = {}) paginate "repos/#{Repository.new repo}/tags", end |
#test_hook(repo, id, options = {}) ⇒ Boolean
Test hook
Requires authenticated client.
566 567 568 |
# File 'lib/octokit/client/repositories.rb', line 566 def test_hook(repo, id, = {}) boolean_from_response :post, "repos/#{Repository.new repo}/hooks/#{id}/tests", end |
#unstar(repo, options = {}) ⇒ Boolean
Unstar a repository
102 103 104 |
# File 'lib/octokit/client/repositories.rb', line 102 def unstar(repo, = {}) boolean_from_response :delete, "user/starred/#{Repository.new repo}", end |
#unwatch(repo, options = {}) ⇒ Boolean
Use #unstar instead
Unwatch a repository
122 123 124 |
# File 'lib/octokit/client/repositories.rb', line 122 def unwatch(repo, = {}) boolean_from_response :delete, "user/watched/#{Repository.new repo}", end |
#update_subscription(repo, options = {}) ⇒ Sawyer::Resource
Update repository subscription
635 636 637 |
# File 'lib/octokit/client/repositories.rb', line 635 def update_subscription(repo, = {}) put "repos/#{Repository.new repo}/subscription", end |
#watch(repo, options = {}) ⇒ Boolean
Use #star instead
Watch a repository
112 113 114 |
# File 'lib/octokit/client/repositories.rb', line 112 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.
357 358 359 |
# File 'lib/octokit/client/repositories.rb', line 357 def watchers(repo, = {}) paginate "repos/#{Repository.new repo}/watchers", end |