Module: Octokit::Client::Repositories
- Included in:
- Octokit::Client
- Defined in:
- lib/octokit/client/repositories.rb
Instance Method Summary collapse
-
#add_collaborator(repo, collaborator, options = {}) ⇒ Boolean
(also: #add_collab)
Add collaborator to repo.
-
#add_deploy_key(repo, title, key, options = {}) ⇒ Hashie::Mash
Add deploy key to a repo.
-
#branch(repo, branch, options = {}) ⇒ Branch
(also: #get_branch)
Get a single branch from a repository.
-
#branches(repo, options = {}) ⇒ Array<Hashie::Mash>
List branches.
-
#collaborators(repo, options = {}) ⇒ Array<Hashie::Mash>
(also: #collabs)
List collaborators.
-
#contributors(repo, anon = false, options = {}) ⇒ Array<Hashie::Mash>
(also: #contribs)
List contributors to a repo.
-
#create_hook(repo, name, config, options = {}) ⇒ Object
Create a hook.
-
#create_repository(name, options = {}) ⇒ Hashie::Mash
(also: #create_repo, #create)
Create a repository for a user or organization.
-
#delete_repository(repo, options = {}) ⇒ Boolean
(also: #delete_repo)
Delete repository.
-
#deploy_keys(repo, options = {}) ⇒ Array<Hashie::Mash>
(also: #list_deploy_keys)
Get deploy keys on a repo.
-
#edit_hook(repo, id, name, config, options = {}) ⇒ Object
Edit a hook.
-
#edit_repository(repo, options = {}) ⇒ Hashie::Mash
(also: #edit, #update_repository, #update)
Edit a repository.
-
#fork(repo, options = {}) ⇒ Hashie::Mash
Fork a repository.
-
#forks(repo, options = {}) ⇒ Array<Hashie::Mash>
(also: #network)
List forks.
-
#hook(repo, id, options = {}) ⇒ Hashie::Mash
Get single hook.
-
#hooks(repo, options = {}) ⇒ Array<Hashie::Mash>
List repo hooks.
-
#languages(repo, options = {}) ⇒ Array<Hashie::Mash>
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<Hashie::Mash>
(also: #list_repositories, #list_repos, #repos)
List repositories.
-
#repository(repo, options = {}) ⇒ Hashie::Mash
(also: #repo)
Get a single repository.
-
#repository_assignees(repo, options = {}) ⇒ Object
(also: #repo_assignees)
List users available for assigning to issues.
-
#repository_issue_events(repo, options = {}) ⇒ Array
(also: #repo_issue_events)
Get all Issue Events for a given Repository.
-
#repository_teams(repo, options = {}) ⇒ Array<Hashie::Mash>
(also: #repo_teams, #teams)
List teams for a repo.
-
#search_repositories(q, options = {}) ⇒ Array<Hashie::Mash>
(also: #search_repos)
Legacy repository search.
-
#set_private(repo, options = {}) ⇒ Hashie::Mash
Hide a public repository.
-
#set_public(repo, options = {}) ⇒ Hashie::Mash
Unhide a private repository.
-
#star(repo, options = {}) ⇒ Boolean
Star a repository.
-
#stargazers(repo, options = {}) ⇒ Array<Hashie::Mash>
List stargazers of a repo.
-
#tags(repo, options = {}) ⇒ Array<Hashie::Mash>
List tags.
-
#test_hook(repo, id, options = {}) ⇒ nil
Test hook.
-
#unstar(repo, options = {}) ⇒ Boolean
Unstar a repository.
-
#unwatch(repo, options = {}) ⇒ Boolean
deprecated
Deprecated.
Use #unstar instead
-
#watch(repo, options = {}) ⇒ Boolean
deprecated
Deprecated.
Use #star instead
-
#watchers(repo, options = {}) ⇒ Array<Hashie::Mash>
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.
269 270 271 |
# File 'lib/octokit/client/repositories.rb', line 269 def add_collaborator(repo, collaborator, ={}) put "repos/#{Repository.new repo}/collaborators/#{collaborator}", , 3 end |
#add_deploy_key(repo, title, key, options = {}) ⇒ Hashie::Mash
Add deploy key to a repo
Requires authenticated client.
218 219 220 |
# File 'lib/octokit/client/repositories.rb', line 218 def add_deploy_key(repo, title, key, ={}) post "repos/#{Repository.new repo}/keys", .merge(:title => title, :key => key), 3 end |
#branch(repo, branch, options = {}) ⇒ Branch Also known as: get_branch
Get a single branch from a repository
442 443 444 |
# File 'lib/octokit/client/repositories.rb', line 442 def branch(repo, branch, ={}) get "repos/#{Repository.new repo}/branches/#{branch}", , 3 end |
#branches(repo, options = {}) ⇒ Array<Hashie::Mash>
List branches
Requires authenticated client for private repos.
430 431 432 |
# File 'lib/octokit/client/repositories.rb', line 430 def branches(repo, ={}) get "repos/#{Repository.new repo}/branches", , 3 end |
#collaborators(repo, options = {}) ⇒ Array<Hashie::Mash> 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, ={}) get "repos/#{Repository.new repo}/collaborators", , 3 end |
#contributors(repo, anon = false, options = {}) ⇒ Array<Hashie::Mash> Also known as: contribs
List contributors to a repo
Requires authenticated client for private repos.
327 328 329 |
# File 'lib/octokit/client/repositories.rb', line 327 def contributors(repo, anon=false, ={}) get "repos/#{Repository.new repo}/contributors", .merge(:anon => anon), 3 end |
#create_hook(repo, name, config, options = {}) ⇒ Object
Create a hook
Requires authenticated client.
507 508 509 510 |
# File 'lib/octokit/client/repositories.rb', line 507 def create_hook(repo, name, config, ={}) = {:name => name, :config => config, :events => ["push"], :active => true}.merge() post "repos/#{Repository.new repo}/hooks", , 3 end |
#create_repository(name, options = {}) ⇒ Hashie::Mash Also known as: create_repo, create
Create a repository for a user or organization
141 142 143 144 145 146 147 148 149 150 |
# File 'lib/octokit/client/repositories.rb', line 141 def create_repository(name, ={}) organization = .delete :organization .merge! :name => name if organization.nil? post 'user/repos', , 3 else post "orgs/#{organization}/repos", , 3 end end |
#delete_repository(repo, options = {}) ⇒ Boolean Also known as: delete_repo
Delete repository
Note: If OAuth is used, ‘delete_repo’ scope is required
161 162 163 164 165 166 167 168 |
# File 'lib/octokit/client/repositories.rb', line 161 def delete_repository(repo, ={}) begin delete "repos/#{Repository.new repo}", , 3 return true rescue Octokit::NotFound return false end end |
#deploy_keys(repo, options = {}) ⇒ Array<Hashie::Mash> Also known as: list_deploy_keys
Get deploy keys on a repo
Requires authenticated client.
201 202 203 |
# File 'lib/octokit/client/repositories.rb', line 201 def deploy_keys(repo, ={}) get "repos/#{Repository.new repo}/keys", , 3 end |
#edit_hook(repo, id, name, config, options = {}) ⇒ Object
Edit a hook
Requires authenticated client.
549 550 551 552 |
# File 'lib/octokit/client/repositories.rb', line 549 def edit_hook(repo, id, name, config, ={}) = {:name => name, :config => config, :events => ["push"], :active => true}.merge() patch "repos/#{Repository.new repo}/hooks/#{id}", , 3 end |
#edit_repository(repo, options = {}) ⇒ Hashie::Mash Also known as: edit, update_repository, update
Edit a repository
38 39 40 |
# File 'lib/octokit/client/repositories.rb', line 38 def edit_repository(repo, ={}) patch "repos/#{Repository.new repo}", , 3 end |
#fork(repo, options = {}) ⇒ Hashie::Mash
Fork a repository
122 123 124 |
# File 'lib/octokit/client/repositories.rb', line 122 def fork(repo, ={}) post "repos/#{Repository.new repo}/forks", , 3 end |
#forks(repo, options = {}) ⇒ Array<Hashie::Mash> Also known as: network
List forks
Requires authenticated client for private repos.
381 382 383 |
# File 'lib/octokit/client/repositories.rb', line 381 def forks(repo, ={}) get "repos/#{Repository.new repo}/forks", , 3 end |
#hook(repo, id, options = {}) ⇒ Hashie::Mash
Get single hook
Requires authenticated client.
472 473 474 |
# File 'lib/octokit/client/repositories.rb', line 472 def hook(repo, id, ={}) get "repos/#{Repository.new repo}/hooks/#{id}", , 3 end |
#hooks(repo, options = {}) ⇒ Array<Hashie::Mash>
List repo hooks
Requires authenticated client.
457 458 459 |
# File 'lib/octokit/client/repositories.rb', line 457 def hooks(repo, ={}) get "repos/#{Repository.new repo}/hooks", , 3 end |
#languages(repo, options = {}) ⇒ Array<Hashie::Mash>
List languages of code in the repo.
Requires authenticated client for private repos.
398 399 400 |
# File 'lib/octokit/client/repositories.rb', line 398 def languages(repo, ={}) get "repos/#{Repository.new repo}/languages", , 3 end |
#remove_collaborator(repo, collaborator, options = {}) ⇒ Boolean Also known as: remove_collab
Remove collaborator from repo.
Requires authenticated client.
287 288 289 |
# File 'lib/octokit/client/repositories.rb', line 287 def remove_collaborator(repo, collaborator, ={}) delete "repos/#{Repository.new repo}/collaborators/#{collaborator}", , 3 end |
#remove_deploy_key(repo, id, options = {}) ⇒ Boolean
Remove deploy key from a repo
Requires authenticated client.
233 234 235 |
# File 'lib/octokit/client/repositories.rb', line 233 def remove_deploy_key(repo, id, ={}) delete "repos/#{Repository.new repo}/keys/#{id}", , 3 end |
#remove_hook(repo, id, options = {}) ⇒ Boolean
Delete hook
Requires authenticated client.
565 566 567 |
# File 'lib/octokit/client/repositories.rb', line 565 def remove_hook(repo, id, ={}) delete "repos/#{Repository.new repo}/hooks/#{id}", , 3 end |
#repositories(username = nil, options = {}) ⇒ Array<Hashie::Mash> Also known as: list_repositories, list_repos, repos
List repositories
If username is not supplied, repositories for the current authenticated user are returned
53 54 55 56 57 58 59 |
# File 'lib/octokit/client/repositories.rb', line 53 def repositories(username=nil, ={}) if username.nil? get 'user/repos', , 3 else get "users/#{username}/repos", , 3 end end |
#repository(repo, options = {}) ⇒ Hashie::Mash Also known as: repo
Get a single repository
20 21 22 |
# File 'lib/octokit/client/repositories.rb', line 20 def repository(repo, ={}) get "repos/#{Repository.new repo}", , 3 end |
#repository_assignees(repo, options = {}) ⇒ Object Also known as: repo_assignees
List users available for assigning to issues.
Requires authenticated client for private repos.
611 612 613 |
# File 'lib/octokit/client/repositories.rb', line 611 def repository_assignees(repo, ={}) get "repos/#{Repository.new repo}/assignees", , 3 end |
#repository_issue_events(repo, options = {}) ⇒ Array Also known as: repo_issue_events
Get all Issue Events for a given Repository
592 593 594 |
# File 'lib/octokit/client/repositories.rb', line 592 def repository_issue_events(repo, ={}) get "repos/#{Repository.new repo}/issues/events", , 3 end |
#repository_teams(repo, options = {}) ⇒ Array<Hashie::Mash> Also known as: repo_teams, teams
List teams for a repo
Requires authenticated client that is an owner or collaborator of the repo.
306 307 308 |
# File 'lib/octokit/client/repositories.rb', line 306 def repository_teams(repo, ={}) get "repos/#{Repository.new repo}/teams", , 3 end |
#search_repositories(q, options = {}) ⇒ Array<Hashie::Mash> Also known as: search_repos
Legacy repository search
10 11 12 |
# File 'lib/octokit/client/repositories.rb', line 10 def search_repositories(q, ={}) get("legacy/repos/search/#{q}", , 3)['repositories'] end |
#set_private(repo, options = {}) ⇒ Hashie::Mash
Hide a public repository
175 176 177 178 |
# File 'lib/octokit/client/repositories.rb', line 175 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 = {}) ⇒ Hashie::Mash
Unhide a private repository
184 185 186 187 |
# File 'lib/octokit/client/repositories.rb', line 184 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
68 69 70 71 72 73 74 75 |
# File 'lib/octokit/client/repositories.rb', line 68 def star(repo, ={}) begin put "user/starred/#{Repository.new repo}", , 3 return true rescue Octokit::NotFound return false end end |
#stargazers(repo, options = {}) ⇒ Array<Hashie::Mash>
List stargazers of a repo
Requires authenticated client for private repos.
344 345 346 |
# File 'lib/octokit/client/repositories.rb', line 344 def stargazers(repo, ={}) get "repos/#{Repository.new repo}/stargazers", , 3 end |
#tags(repo, options = {}) ⇒ Array<Hashie::Mash>
List tags
Requires authenticated client for private repos.
414 415 416 |
# File 'lib/octokit/client/repositories.rb', line 414 def (repo, ={}) get "repos/#{Repository.new repo}/tags", , 3 end |
#test_hook(repo, id, options = {}) ⇒ nil
Test hook
Requires authenticated client.
580 581 582 |
# File 'lib/octokit/client/repositories.rb', line 580 def test_hook(repo, id, ={}) post "repos/#{Repository.new repo}/hooks/#{id}/test", , 3 end |
#unstar(repo, options = {}) ⇒ Boolean
Unstar a repository
81 82 83 84 85 86 87 88 |
# File 'lib/octokit/client/repositories.rb', line 81 def unstar(repo, ={}) begin delete "user/starred/#{Repository.new repo}", , 3 return true rescue Octokit::NotFound return false end end |
#unwatch(repo, options = {}) ⇒ Boolean
Use #unstar instead
Unwatch a repository
109 110 111 112 113 114 115 116 |
# File 'lib/octokit/client/repositories.rb', line 109 def unwatch(repo, ={}) begin delete "user/watched/#{Repository.new repo}", , 3 return true rescue Octokit::NotFound return false end end |
#watch(repo, options = {}) ⇒ Boolean
Use #star instead
Watch a repository
95 96 97 98 99 100 101 102 |
# File 'lib/octokit/client/repositories.rb', line 95 def watch(repo, ={}) begin put "user/watched/#{Repository.new repo}", , 3 return true rescue Octokit::NotFound return false end end |
#watchers(repo, options = {}) ⇒ Array<Hashie::Mash>
Use #stargazers instead
List watchers of repo.
Requires authenticated client for private repos.
363 364 365 |
# File 'lib/octokit/client/repositories.rb', line 363 def watchers(repo, ={}) get "repos/#{Repository.new repo}/watchers", , 3 end |