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.
-
#all_repositories(options = {}) ⇒ Array
List all repositories.
-
#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.
-
#delete_subscription(repo, options = {}) ⇒ Boolean
Delete a repository subscription.
-
#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 = {}) ⇒ Array<Hashie::Mash>
(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.
-
#subscribers(repo, options = {}) ⇒ Array
List watchers subscribing to notifications for a repo.
-
#subscription(repo, options = {}) ⇒ Hashie::Mash
Get a repository subscription.
-
#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
-
#update_subscription(repo, options = {}) ⇒ Hashie::Mash
Update repository subscription.
-
#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.
261 262 263 |
# File 'lib/octokit/client/repositories.rb', line 261 def add_collaborator(repo, collaborator, ={}) boolean_from_response(:put, "repos/#{Repository.new repo}/collaborators/#{collaborator}", ) end |
#add_deploy_key(repo, title, key, options = {}) ⇒ Hashie::Mash
Add deploy key to a repo
Requires authenticated client.
210 211 212 |
# File 'lib/octokit/client/repositories.rb', line 210 def add_deploy_key(repo, title, key, ={}) post "repos/#{Repository.new repo}/keys", .merge(:title => title, :key => key) end |
#all_repositories(options = {}) ⇒ Array
List all repositories
This provides a dump of every repository, in the order that they were created.
77 78 79 |
# File 'lib/octokit/client/repositories.rb', line 77 def all_repositories(={}) get '/repositories', end |
#branch(repo, branch, options = {}) ⇒ Branch Also known as: get_branch
Get a single branch from a repository
434 435 436 |
# File 'lib/octokit/client/repositories.rb', line 434 def branch(repo, branch, ={}) get "repos/#{Repository.new repo}/branches/#{branch}", end |
#branches(repo, options = {}) ⇒ Array<Hashie::Mash>
List branches
Requires authenticated client for private repos.
422 423 424 |
# File 'lib/octokit/client/repositories.rb', line 422 def branches(repo, ={}) get "repos/#{Repository.new repo}/branches", end |
#collaborators(repo, options = {}) ⇒ Array<Hashie::Mash> Also known as: collabs
List collaborators
Requires authenticated client for private repos.
243 244 245 |
# File 'lib/octokit/client/repositories.rb', line 243 def collaborators(repo, ={}) get "repos/#{Repository.new repo}/collaborators", end |
#contributors(repo, anon = false, options = {}) ⇒ Array<Hashie::Mash> Also known as: contribs
List contributors to a repo
Requires authenticated client for private repos.
319 320 321 |
# File 'lib/octokit/client/repositories.rb', line 319 def contributors(repo, anon=false, ={}) get "repos/#{Repository.new repo}/contributors", .merge(:anon => anon) end |
#create_hook(repo, name, config, options = {}) ⇒ Object
Create a hook
Requires authenticated client.
499 500 501 502 |
# File 'lib/octokit/client/repositories.rb', line 499 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 = {}) ⇒ Hashie::Mash Also known as: create_repo, create
Create a repository for a user or organization
138 139 140 141 142 143 144 145 146 147 |
# File 'lib/octokit/client/repositories.rb', line 138 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
158 159 160 |
# File 'lib/octokit/client/repositories.rb', line 158 def delete_repository(repo, ={}) boolean_from_response(:delete, "repos/#{Repository.new repo}", ) end |
#delete_subscription(repo, options = {}) ⇒ Boolean
Delete a repository subscription
667 668 669 |
# File 'lib/octokit/client/repositories.rb', line 667 def delete_subscription(repo, ={}) boolean_from_response(:delete, "repos/#{Repository.new repo}/subscription", ) end |
#deploy_keys(repo, options = {}) ⇒ Array<Hashie::Mash> Also known as: list_deploy_keys
Get deploy keys on a repo
Requires authenticated client.
193 194 195 |
# File 'lib/octokit/client/repositories.rb', line 193 def deploy_keys(repo, ={}) get "repos/#{Repository.new repo}/keys", end |
#edit_hook(repo, id, name, config, options = {}) ⇒ Object
Edit a hook
Requires authenticated client.
541 542 543 544 |
# File 'lib/octokit/client/repositories.rb', line 541 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 = {}) ⇒ Hashie::Mash Also known as: edit, update_repository, update
Edit a repository
39 40 41 |
# File 'lib/octokit/client/repositories.rb', line 39 def edit_repository(repo, ={}) patch "repos/#{Repository.new repo}", end |
#fork(repo, options = {}) ⇒ Hashie::Mash
Fork a repository
119 120 121 |
# File 'lib/octokit/client/repositories.rb', line 119 def fork(repo, ={}) post "repos/#{Repository.new repo}/forks", end |
#forks(repo, options = {}) ⇒ Array<Hashie::Mash> Also known as: network
List forks
Requires authenticated client for private repos.
373 374 375 |
# File 'lib/octokit/client/repositories.rb', line 373 def forks(repo, ={}) get "repos/#{Repository.new repo}/forks", end |
#hook(repo, id, options = {}) ⇒ Hashie::Mash
Get single hook
Requires authenticated client.
464 465 466 |
# File 'lib/octokit/client/repositories.rb', line 464 def hook(repo, id, ={}) get "repos/#{Repository.new repo}/hooks/#{id}", end |
#hooks(repo, options = {}) ⇒ Array<Hashie::Mash>
List repo hooks
Requires authenticated client.
449 450 451 |
# File 'lib/octokit/client/repositories.rb', line 449 def hooks(repo, ={}) get "repos/#{Repository.new repo}/hooks", end |
#languages(repo, options = {}) ⇒ Array<Hashie::Mash>
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, ={}) get "repos/#{Repository.new repo}/languages", end |
#remove_collaborator(repo, collaborator, options = {}) ⇒ Boolean Also known as: remove_collab
Remove collaborator from repo.
Requires authenticated client.
279 280 281 |
# File 'lib/octokit/client/repositories.rb', line 279 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.
225 226 227 |
# File 'lib/octokit/client/repositories.rb', line 225 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.
557 558 559 |
# File 'lib/octokit/client/repositories.rb', line 557 def remove_hook(repo, id, ={}) boolean_from_response(:delete, "repos/#{Repository.new repo}/hooks/#{id}", ) 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
54 55 56 57 58 59 60 |
# File 'lib/octokit/client/repositories.rb', line 54 def repositories(username=nil, ={}) if username.nil? get 'user/repos', else get "users/#{username}/repos", 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}", end |
#repository_assignees(repo, options = {}) ⇒ Array<Hashie::Mash> Also known as: repo_assignees
List users available for assigning to issues.
Requires authenticated client for private repos.
603 604 605 |
# File 'lib/octokit/client/repositories.rb', line 603 def repository_assignees(repo, ={}) get "repos/#{Repository.new repo}/assignees", end |
#repository_issue_events(repo, options = {}) ⇒ Array Also known as: repo_issue_events
Get all Issue Events for a given Repository
584 585 586 |
# File 'lib/octokit/client/repositories.rb', line 584 def repository_issue_events(repo, ={}) get "repos/#{Repository.new repo}/issues/events", 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.
298 299 300 |
# File 'lib/octokit/client/repositories.rb', line 298 def repository_teams(repo, ={}) get "repos/#{Repository.new repo}/teams", 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}", )['repositories'] end |
#set_private(repo, options = {}) ⇒ Hashie::Mash
Hide a public repository
167 168 169 170 |
# File 'lib/octokit/client/repositories.rb', line 167 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
176 177 178 179 |
# File 'lib/octokit/client/repositories.rb', line 176 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
85 86 87 |
# File 'lib/octokit/client/repositories.rb', line 85 def star(repo, ={}) boolean_from_response(:put, "user/starred/#{Repository.new repo}", ) end |
#stargazers(repo, options = {}) ⇒ Array<Hashie::Mash>
List stargazers of a repo
Requires authenticated client for private repos.
336 337 338 |
# File 'lib/octokit/client/repositories.rb', line 336 def stargazers(repo, ={}) get "repos/#{Repository.new repo}/stargazers", end |
#subscribers(repo, options = {}) ⇒ Array
List watchers subscribing to notifications for a repo
618 619 620 |
# File 'lib/octokit/client/repositories.rb', line 618 def subscribers(repo, ={}) get("repos/#{Repository.new repo}/subscribers", ) end |
#subscription(repo, options = {}) ⇒ Hashie::Mash
Get a repository subscription
632 633 634 |
# File 'lib/octokit/client/repositories.rb', line 632 def subscription(repo, ={}) get("repos/#{Repository.new repo}/subscription", ) end |
#tags(repo, options = {}) ⇒ Array<Hashie::Mash>
List tags
Requires authenticated client for private repos.
406 407 408 |
# File 'lib/octokit/client/repositories.rb', line 406 def (repo, ={}) get "repos/#{Repository.new repo}/tags", end |
#test_hook(repo, id, options = {}) ⇒ nil
Test hook
Requires authenticated client.
572 573 574 |
# File 'lib/octokit/client/repositories.rb', line 572 def test_hook(repo, id, ={}) boolean_from_response(:post, "repos/#{Repository.new repo}/hooks/#{id}/tests", ) end |
#unstar(repo, options = {}) ⇒ Boolean
Unstar a repository
93 94 95 |
# File 'lib/octokit/client/repositories.rb', line 93 def unstar(repo, ={}) boolean_from_response(:delete, "user/starred/#{Repository.new repo}", ) end |
#unwatch(repo, options = {}) ⇒ Boolean
Use #unstar instead
Unwatch a repository
111 112 113 |
# File 'lib/octokit/client/repositories.rb', line 111 def unwatch(repo, ={}) boolean_from_response(:delete, "user/watched/#{Repository.new repo}", ) end |
#update_subscription(repo, options = {}) ⇒ Hashie::Mash
Update repository subscription
653 654 655 |
# File 'lib/octokit/client/repositories.rb', line 653 def update_subscription(repo, ={}) put("repos/#{Repository.new repo}/subscription", ) end |
#watch(repo, options = {}) ⇒ Boolean
Use #star instead
Watch a repository
102 103 104 |
# File 'lib/octokit/client/repositories.rb', line 102 def watch(repo, ={}) boolean_from_response(:put, "user/watched/#{Repository.new repo}", ) end |
#watchers(repo, options = {}) ⇒ Array<Hashie::Mash>
Use #stargazers instead
List watchers of repo.
Requires authenticated client for private repos.
355 356 357 |
# File 'lib/octokit/client/repositories.rb', line 355 def watchers(repo, ={}) get "repos/#{Repository.new repo}/watchers", end |