Module: Octokit::Client::Repositories

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

Instance Method Summary collapse

Instance Method Details

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



90
91
92
# File 'lib/octokit/client/repositories.rb', line 90

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

#add_deploy_key(repo, title, key, options = {}) ⇒ Object



77
78
79
# File 'lib/octokit/client/repositories.rb', line 77

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

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

Get a single branch from a repository

Examples:

Get branch ‘master` from pengwynn/octokit

Octokit.issue("pengwynn/octokit", "master")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

  • branch (String)

    Branch name

Returns:

  • (Branch)

    The branch requested, if it exists

See Also:



140
141
142
# File 'lib/octokit/client/repositories.rb', line 140

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

#branches(repo, options = {}) ⇒ Object



128
129
130
# File 'lib/octokit/client/repositories.rb', line 128

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

#collaborators(repo, options = {}) ⇒ Object Also known as: collabs



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

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

#contributors(repo, anon = false, options = {}) ⇒ Object Also known as: contribs



106
107
108
# File 'lib/octokit/client/repositories.rb', line 106

def contributors(repo, anon=false, options={})
  get "repos/#{Repository.new repo}/contributors", options.merge(:anon => anon), 3
end

#create_hook(repo, name, config, options = {}) ⇒ Object



153
154
155
156
# File 'lib/octokit/client/repositories.rb', line 153

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, 3
end

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



44
45
46
47
48
49
50
51
52
53
# File 'lib/octokit/client/repositories.rb', line 44

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

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

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



57
58
59
# File 'lib/octokit/client/repositories.rb', line 57

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

#deploy_keys(repo, options = {}) ⇒ Object Also known as: list_deploy_keys



72
73
74
# File 'lib/octokit/client/repositories.rb', line 72

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

#edit_hook(repo, id, name, config, options = {}) ⇒ Object



158
159
160
161
# File 'lib/octokit/client/repositories.rb', line 158

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, 3
end

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



14
15
16
# File 'lib/octokit/client/repositories.rb', line 14

def edit_repository(repo, options={})
  patch "repos/#{Repository.new repo}", options, 3
end

#fork(repo, options = {}) ⇒ Object



40
41
42
# File 'lib/octokit/client/repositories.rb', line 40

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

#forks(repo, options = {}) ⇒ Object Also known as: network



115
116
117
# File 'lib/octokit/client/repositories.rb', line 115

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

#hook(repo, id, options = {}) ⇒ Object



149
150
151
# File 'lib/octokit/client/repositories.rb', line 149

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

#hooks(repo, options = {}) ⇒ Object



145
146
147
# File 'lib/octokit/client/repositories.rb', line 145

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

#languages(repo, options = {}) ⇒ Object



120
121
122
# File 'lib/octokit/client/repositories.rb', line 120

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

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



95
96
97
# File 'lib/octokit/client/repositories.rb', line 95

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

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



81
82
83
# File 'lib/octokit/client/repositories.rb', line 81

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

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



163
164
165
# File 'lib/octokit/client/repositories.rb', line 163

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

#repositories(username = nil, options = {}) ⇒ Object Also known as: list_repositories, list_repos, repos



21
22
23
24
25
26
27
# File 'lib/octokit/client/repositories.rb', line 21

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

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



9
10
11
# File 'lib/octokit/client/repositories.rb', line 9

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

#repository_assignees(repo, options = {}) ⇒ Object Also known as: repo_assignees



184
185
186
# File 'lib/octokit/client/repositories.rb', line 184

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

#repository_issue_events(repo, options = {}) ⇒ Array Also known as: repo_issue_events

Get all Issue Events for a given Repository

Examples:

Get all Issue Events for Octokit

Octokit.repository_issue_events("pengwynn/octokit")

Parameters:

  • repo (String, Repository, Hash)

    A GitHub repository

Returns:

  • (Array)

    Array of all Issue Events for this Repository

See Also:



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

def repository_issue_events(repo, options={})
  get "repos/#{Repository.new repo}/issues/events", options, 3
end

#repository_teams(repo, options = {}) ⇒ Object Also known as: repo_teams, teams



100
101
102
# File 'lib/octokit/client/repositories.rb', line 100

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

#search_repositories(q, options = {}) ⇒ Object Also known as: search_repos



4
5
6
# File 'lib/octokit/client/repositories.rb', line 4

def search_repositories(q, options={})
  get("legacy/repos/search/#{q}", options, 3)['repositories']
end

#set_private(repo, options = {}) ⇒ Object



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

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 = {}) ⇒ Object



67
68
69
70
# File 'lib/octokit/client/repositories.rb', line 67

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

#tags(repo, options = {}) ⇒ Object



124
125
126
# File 'lib/octokit/client/repositories.rb', line 124

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

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



167
168
169
# File 'lib/octokit/client/repositories.rb', line 167

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

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



36
37
38
# File 'lib/octokit/client/repositories.rb', line 36

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

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



32
33
34
# File 'lib/octokit/client/repositories.rb', line 32

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

#watchers(repo, options = {}) ⇒ Object



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

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