octokit 3.1.2 → 3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -8,14 +8,14 @@ module Octokit
8
8
 
9
9
  # List all refs for a given user and repo
10
10
  #
11
- # @param repo [String, Repository, Hash] A GitHub repository
11
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
12
12
  # @param namespace [String] The ref namespace, e.g. <tt>tag</tt> or <tt>heads</tt>
13
13
  # @return [Array<Sawyer::Resource>] A list of references matching the repo and the namespace
14
14
  # @see https://developer.github.com/v3/git/refs/#get-all-references
15
15
  # @example Fetch all refs for sferik/rails_admin
16
16
  # Octokit.refs("sferik/rails_admin")
17
17
  def refs(repo, namespace = nil, options = {})
18
- path = "repos/#{Repository.new(repo)}/git/refs"
18
+ path = "#{Repository.path repo}/git/refs"
19
19
  path += "/#{namespace}" unless namespace.nil?
20
20
  paginate path, options
21
21
  end
@@ -25,20 +25,20 @@ module Octokit
25
25
 
26
26
  # Fetch a given reference
27
27
  #
28
- # @param repo [String, Repository, Hash] A GitHub repository
28
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
29
29
  # @param ref [String] The ref, e.g. <tt>tags/v0.0.3</tt>
30
30
  # @return [Sawyer::Resource] The reference matching the given repo and the ref id
31
31
  # @see https://developer.github.com/v3/git/refs/#get-a-reference
32
32
  # @example Fetch tags/v0.0.3 for sferik/rails_admin
33
33
  # Octokit.ref("sferik/rails_admin","tags/v0.0.3")
34
34
  def ref(repo, ref, options = {})
35
- get "repos/#{Repository.new(repo)}/git/refs/#{ref}", options
35
+ get "#{Repository.path repo}/git/refs/#{ref}", options
36
36
  end
37
37
  alias :reference :ref
38
38
 
39
39
  # Create a reference
40
40
  #
41
- # @param repo [String, Repository, Hash] A GitHub repository
41
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
42
42
  # @param ref [String] The ref, e.g. <tt>tags/v0.0.3</tt>
43
43
  # @param sha [String] A SHA, e.g. <tt>827efc6d56897b048c772eb4087f854f46256132</tt>
44
44
  # @return [Array<Sawyer::Resource>] The list of references, already containing the new one
@@ -50,13 +50,13 @@ module Octokit
50
50
  :ref => "refs/#{ref}",
51
51
  :sha => sha
52
52
  }
53
- post "repos/#{Repository.new(repo)}/git/refs", options.merge(parameters)
53
+ post "#{Repository.path repo}/git/refs", options.merge(parameters)
54
54
  end
55
55
  alias :create_reference :create_ref
56
56
 
57
57
  # Update a reference
58
58
  #
59
- # @param repo [String, Repository, Hash] A GitHub repository
59
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
60
60
  # @param ref [String] The ref, e.g. <tt>tags/v0.0.3</tt>
61
61
  # @param sha [String] A SHA, e.g. <tt>827efc6d56897b048c772eb4087f854f46256132</tt>
62
62
  # @param force [Boolean] A flag indicating one wants to force the update to make sure the update is a fast-forward update.
@@ -69,13 +69,13 @@ module Octokit
69
69
  :sha => sha,
70
70
  :force => force
71
71
  }
72
- patch "repos/#{Repository.new(repo)}/git/refs/#{ref}", options.merge(parameters)
72
+ patch "#{Repository.path repo}/git/refs/#{ref}", options.merge(parameters)
73
73
  end
74
74
  alias :update_reference :update_ref
75
75
 
76
76
  # Update a branch
77
77
  #
78
- # @param repo [String, Repository, Hash] A GitHub repository
78
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
79
79
  # @param branch [String] The ref, e.g. <tt>feature/new-shiny</tt>
80
80
  # @param sha [String] A SHA, e.g. <tt>827efc6d56897b048c772eb4087f854f46256132</tt>
81
81
  # @param force [Boolean] A flag indicating one wants to force the update to make sure the update is a fast-forward update.
@@ -89,7 +89,7 @@ module Octokit
89
89
 
90
90
  # Delete a single branch
91
91
  #
92
- # @param repo [String, Repository, Hash] A GitHub repository
92
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
93
93
  # @param branch [String] The branch, e.g. <tt>fix-refs</tt>
94
94
  # @return [Boolean] Success
95
95
  # @see https://developer.github.com/v3/git/refs/#delete-a-reference
@@ -101,14 +101,14 @@ module Octokit
101
101
 
102
102
  # Delete a single reference
103
103
  #
104
- # @param repo [String, Repository, Hash] A GitHub repository
104
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
105
105
  # @param ref [String] The ref, e.g. <tt>tags/v0.0.3</tt>
106
106
  # @return [Boolean] Success
107
107
  # @see https://developer.github.com/v3/git/refs/#delete-a-reference
108
108
  # @example Delete tags/v0.0.3 for sferik/rails_admin
109
109
  # Octokit.delete_ref("sferik/rails_admin","tags/v0.0.3")
110
110
  def delete_ref(repo, ref, options = {})
111
- boolean_from_response :delete, "repos/#{Repository.new(repo)}/git/refs/#{ref}", options
111
+ boolean_from_response :delete, "#{Repository.path repo}/git/refs/#{ref}", options
112
112
  end
113
113
  alias :delete_reference :delete_ref
114
114
 
@@ -8,17 +8,17 @@ module Octokit
8
8
 
9
9
  # List releases for a repository
10
10
  #
11
- # @param repo [String, Repository, Hash] A GitHub repository
11
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
12
12
  # @return [Array<Sawyer::Resource>] A list of releases
13
13
  # @see https://developer.github.com/v3/repos/releases/#list-releases-for-a-repository
14
14
  def releases(repo, options = {})
15
- paginate "repos/#{Repository.new(repo)}/releases", options
15
+ paginate "#{Repository.path repo}/releases", options
16
16
  end
17
17
  alias :list_releases :releases
18
18
 
19
19
  # Create a release
20
20
  #
21
- # @param repo [String, Repository, Hash] A GitHub repository
21
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
22
22
  # @param tag_name [String] Git tag from which to create release
23
23
  # @option options [String] :target_commitish Specifies the commitish value that determines where the Git tag is created from.
24
24
  # @option options [String] :name Name for the release
@@ -29,7 +29,7 @@ module Octokit
29
29
  # @see https://developer.github.com/v3/repos/releases/#create-a-release
30
30
  def create_release(repo, tag_name, options = {})
31
31
  opts = options.merge(:tag_name => tag_name)
32
- post "repos/#{Repository.new(repo)}/releases", opts
32
+ post "#{Repository.path repo}/releases", opts
33
33
  end
34
34
 
35
35
  # Get a release
@@ -9,7 +9,7 @@ module Octokit
9
9
  # Check if a repository exists
10
10
  #
11
11
  # @see https://developer.github.com/v3/repos/#get
12
- # @param repo [String, Hash, Repository] A GitHub repository
12
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
13
13
  # @return [Sawyer::Resource] if a repository exists, false otherwise
14
14
  def repository?(repo, options = {})
15
15
  !!repository(repo, options)
@@ -20,10 +20,10 @@ module Octokit
20
20
  # Get a single repository
21
21
  #
22
22
  # @see https://developer.github.com/v3/repos/#get
23
- # @param repo [String, Hash, Repository] A GitHub repository
23
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
24
24
  # @return [Sawyer::Resource] Repository information
25
25
  def repository(repo, options = {})
26
- get "repos/#{Repository.new(repo)}", options
26
+ get Repository.path(repo), options
27
27
  end
28
28
  alias :repo :repository
29
29
 
@@ -52,23 +52,20 @@ module Octokit
52
52
 
53
53
  # List user repositories
54
54
  #
55
- # If username is not supplied, repositories for the current
55
+ # If user is not supplied, repositories for the current
56
56
  # authenticated user are returned.
57
57
  #
58
- # @note If the username provided is a GitHub organization, only the
58
+ # @note If the user provided is a GitHub organization, only the
59
59
  # organization's public repositories will be listed. For retrieving
60
60
  # organization repositories the {Organizations#organization_repositories}
61
61
  # method should be used instead.
62
62
  # @see https://developer.github.com/v3/repos/#list-your-repositories
63
63
  # @see https://developer.github.com/v3/repos/#list-user-repositories
64
- # @param username [String] Optional username for which to list repos
64
+ # @param user [Integer, String] Optional GitHub user login or id for which
65
+ # to list repos.
65
66
  # @return [Array<Sawyer::Resource>] List of repositories
66
- def repositories(username=nil, options = {})
67
- if username.nil?
68
- paginate 'user/repos', options
69
- else
70
- paginate "users/#{username}/repos", options
71
- end
67
+ def repositories(user=nil, options = {})
68
+ paginate "#{User.path user}/repos", options
72
69
  end
73
70
  alias :list_repositories :repositories
74
71
  alias :list_repos :repositories
@@ -129,11 +126,11 @@ module Octokit
129
126
 
130
127
  # Fork a repository
131
128
  #
132
- # @param repo [String, Hash, Repository] A GitHub repository
129
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
133
130
  # @return [Sawyer::Resource] Repository info for the new fork
134
131
  # @see https://developer.github.com/v3/repos/forks/#create-a-fork
135
132
  def fork(repo, options = {})
136
- post "repos/#{Repository.new(repo)}/forks", options
133
+ post "#{Repository.path repo}/forks", options
137
134
  end
138
135
 
139
136
  # Create a repository for a user or organization
@@ -169,16 +166,16 @@ module Octokit
169
166
  # Note: If OAuth is used, 'delete_repo' scope is required
170
167
  #
171
168
  # @see https://developer.github.com/v3/repos/#delete-a-repository
172
- # @param repo [String, Hash, Repository] A GitHub repository
169
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
173
170
  # @return [Boolean] `true` if repository was deleted
174
171
  def delete_repository(repo, options = {})
175
- boolean_from_response :delete, "repos/#{Repository.new(repo)}", options
172
+ boolean_from_response :delete, Repository.path(repo), options
176
173
  end
177
174
  alias :delete_repo :delete_repository
178
175
 
179
176
  # Hide a public repository
180
177
  #
181
- # @param repo [String, Hash, Repository] A GitHub repository
178
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
182
179
  # @return [Sawyer::Resource] Updated repository info
183
180
  def set_private(repo, options = {})
184
181
  # GitHub Api for setting private updated to use private attr, rather than public
@@ -187,7 +184,7 @@ module Octokit
187
184
 
188
185
  # Unhide a private repository
189
186
  #
190
- # @param repo [String, Hash, Repository] A GitHub repository
187
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
191
188
  # @return [Sawyer::Resource] Updated repository info
192
189
  def set_public(repo, options = {})
193
190
  # GitHub Api for setting private updated to use private attr, rather than public
@@ -198,7 +195,7 @@ module Octokit
198
195
  #
199
196
  # Requires authenticated client.
200
197
  #
201
- # @param repo [String, Hash, Repository] A GitHub repository
198
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository
202
199
  # @return [Array<Sawyer::Resource>] Array of hashes representing deploy keys.
203
200
  # @see https://developer.github.com/v3/repos/keys/#list
204
201
  # @example
@@ -206,27 +203,27 @@ module Octokit
206
203
  # @example
207
204
  # @client.list_deploy_keys('octokit/octokit.rb')
208
205
  def deploy_keys(repo, options = {})
209
- paginate "repos/#{Repository.new(repo)}/keys", options
206
+ paginate "#{Repository.path repo}/keys", options
210
207
  end
211
208
  alias :list_deploy_keys :deploy_keys
212
209
 
213
210
  # Get a single deploy key for a repo
214
211
  #
215
- # @param repo [String, Hash, Repository] A GitHub repository.
212
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
216
213
  # @param id [Integer] Deploy key ID.
217
214
  # @return [Sawyer::Resource] Deploy key.
218
215
  # @see https://developer.github.com/v3/repos/keys/#get
219
216
  # @example
220
217
  # @client.deploy_key('octokit/octokit.rb', 8675309)
221
218
  def deploy_key(repo, id, options={})
222
- get "repos/#{Repository.new(repo)}/keys/#{id}", options
219
+ get "#{Repository.path repo}/keys/#{id}", options
223
220
  end
224
221
 
225
222
  # Add deploy key to a repo
226
223
  #
227
224
  # Requires authenticated client.
228
225
  #
229
- # @param repo [String, Hash, Repository] A GitHub repository.
226
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
230
227
  # @param title [String] Title reference for the deploy key.
231
228
  # @param key [String] Public key.
232
229
  # @return [Sawyer::Resource] Hash representing newly added key.
@@ -234,24 +231,26 @@ module Octokit
234
231
  # @example
235
232
  # @client.add_deploy_key('octokit/octokit.rb', 'Staging server', 'ssh-rsa AAA...')
236
233
  def add_deploy_key(repo, title, key, options = {})
237
- post "repos/#{Repository.new(repo)}/keys", options.merge(:title => title, :key => key)
234
+ post "#{Repository.path repo}/keys", options.merge(:title => title, :key => key)
238
235
  end
239
236
 
240
237
  # Edit a deploy key
241
238
  #
242
- # @param repo [String, Hash, Repository] A GitHub repository.
239
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
243
240
  # @param id [Integer] Deploy key ID.
244
241
  # @param options [Hash] Attributes to edit.
245
242
  # @option title [String] Key title.
246
243
  # @option key [String] Public key.
247
244
  # @return [Sawyer::Resource] Updated deploy key.
245
+ # @deprecated This method is no longer supported in the API
246
+ # @see https://developer.github.com/changes/2014-02-24-finer-grained-scopes-for-ssh-keys/
248
247
  # @see https://developer.github.com/v3/repos/keys/#edit
249
248
  # @example Update the key for a deploy key.
250
249
  # @client.edit_deploy_key('octokit/octokit.rb', 8675309, :key => 'ssh-rsa BBB...')
251
250
  # @example
252
251
  # @client.update_deploy_key('octokit/octokit.rb', 8675309, :title => 'Uber', :key => 'ssh-rsa BBB...'))
253
252
  def edit_deploy_key(repo, id, options)
254
- patch "repos/#{Repository.new(repo)}/keys/#{id}", options
253
+ patch "#{Repository.path repo}/keys/#{id}", options
255
254
  end
256
255
  alias :update_deploy_key :edit_deploy_key
257
256
 
@@ -259,21 +258,21 @@ module Octokit
259
258
  #
260
259
  # Requires authenticated client.
261
260
  #
262
- # @param repo [String, Hash, Repository] A GitHub repository.
261
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
263
262
  # @param id [Integer] Id of the deploy key to remove.
264
263
  # @return [Boolean] True if key removed, false otherwise.
265
264
  # @see https://developer.github.com/v3/repos/keys/#delete
266
265
  # @example
267
266
  # @client.remove_deploy_key('octokit/octokit.rb', 100000)
268
267
  def remove_deploy_key(repo, id, options = {})
269
- boolean_from_response :delete, "repos/#{Repository.new(repo)}/keys/#{id}", options
268
+ boolean_from_response :delete, "#{Repository.path repo}/keys/#{id}", options
270
269
  end
271
270
 
272
271
  # List collaborators
273
272
  #
274
273
  # Requires authenticated client for private repos.
275
274
  #
276
- # @param repo [String, Hash, Repository] A GitHub repository.
275
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
277
276
  # @return [Array<Sawyer::Resource>] Array of hashes representing collaborating users.
278
277
  # @see https://developer.github.com/v3/repos/collaborators/#list
279
278
  # @example
@@ -283,7 +282,7 @@ module Octokit
283
282
  # @example
284
283
  # @client.collabs('octokit/octokit.rb')
285
284
  def collaborators(repo, options = {})
286
- paginate "repos/#{Repository.new(repo)}/collaborators", options
285
+ paginate "#{Repository.path repo}/collaborators", options
287
286
  end
288
287
  alias :collabs :collaborators
289
288
 
@@ -291,7 +290,7 @@ module Octokit
291
290
  #
292
291
  # Requires authenticated client.
293
292
  #
294
- # @param repo [String, Hash, Repository] A GitHub repository.
293
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
295
294
  # @param collaborator [String] Collaborator GitHub username to add.
296
295
  # @return [Boolean] True if collaborator added, false otherwise.
297
296
  # @see https://developer.github.com/v3/repos/collaborators/#add-collaborator
@@ -300,7 +299,7 @@ module Octokit
300
299
  # @example
301
300
  # @client.add_collab('octokit/octokit.rb', 'holman')
302
301
  def add_collaborator(repo, collaborator, options = {})
303
- boolean_from_response :put, "repos/#{Repository.new(repo)}/collaborators/#{collaborator}", options
302
+ boolean_from_response :put, "#{Repository.path repo}/collaborators/#{collaborator}", options
304
303
  end
305
304
  alias :add_collab :add_collaborator
306
305
 
@@ -308,7 +307,7 @@ module Octokit
308
307
  #
309
308
  # Requires authenticated client.
310
309
  #
311
- # @param repo [String, Hash, Repository] A GitHub repository.
310
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
312
311
  # @param collaborator [String] Collaborator GitHub username to remove.
313
312
  # @return [Boolean] True if collaborator removed, false otherwise.
314
313
  # @see https://developer.github.com/v3/repos/collaborators/#remove-collaborator
@@ -317,7 +316,7 @@ module Octokit
317
316
  # @example
318
317
  # @client.remove_collab('octokit/octokit.rb', 'holman')
319
318
  def remove_collaborator(repo, collaborator, options = {})
320
- boolean_from_response :delete, "repos/#{Repository.new(repo)}/collaborators/#{collaborator}", options
319
+ boolean_from_response :delete, "#{Repository.path repo}/collaborators/#{collaborator}", options
321
320
  end
322
321
  alias :remove_collab :remove_collaborator
323
322
 
@@ -325,21 +324,21 @@ module Octokit
325
324
  #
326
325
  # Requires authenticated client.
327
326
  #
328
- # @param repo [String, Hash, Repository] A GitHub repository.
327
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
329
328
  # @param collaborator [String] Collaborator GitHub username to check.
330
329
  # @return [Boolean] True if user is a collaborator, false otherwise.
331
330
  # @see https://developer.github.com/v3/repos/collaborators/#get
332
331
  # @example
333
332
  # @client.collaborator?('octokit/octokit.rb', 'holman')
334
333
  def collaborator?(repo, collaborator, options={})
335
- boolean_from_response :get, "repos/#{Repository.new(repo)}/collaborators/#{collaborator}", options
334
+ boolean_from_response :get, "#{Repository.path repo}/collaborators/#{collaborator}", options
336
335
  end
337
336
 
338
337
  # List teams for a repo
339
338
  #
340
339
  # Requires authenticated client that is an owner or collaborator of the repo.
341
340
  #
342
- # @param repo [String, Hash, Repository] A GitHub repository.
341
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
343
342
  # @return [Array<Sawyer::Resource>] Array of hashes representing teams.
344
343
  # @see https://developer.github.com/v3/repos/#list-teams
345
344
  # @example
@@ -349,7 +348,7 @@ module Octokit
349
348
  # @example
350
349
  # @client.teams('octokit/pengwynn')
351
350
  def repository_teams(repo, options = {})
352
- paginate "repos/#{Repository.new(repo)}/teams", options
351
+ paginate "#{Repository.path repo}/teams", options
353
352
  end
354
353
  alias :repo_teams :repository_teams
355
354
  alias :teams :repository_teams
@@ -358,8 +357,8 @@ module Octokit
358
357
  #
359
358
  # Requires authenticated client for private repos.
360
359
  #
361
- # @param repo [String, Hash, Repository] A GitHub repository.
362
- # @param anon [Boolean] Set true to include annonymous contributors.
360
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
361
+ # @param anon [Boolean] Set true to include anonymous contributors.
363
362
  # @return [Array<Sawyer::Resource>] Array of hashes representing users.
364
363
  # @see https://developer.github.com/v3/repos/#list-contributors
365
364
  # @example
@@ -370,7 +369,7 @@ module Octokit
370
369
  # @client.contribs('octokit/octokit.rb')
371
370
  def contributors(repo, anon = nil, options = {})
372
371
  options[:anon] = 1 if anon.to_s[/1|true/]
373
- paginate "repos/#{Repository.new(repo)}/contributors", options
372
+ paginate "#{Repository.path repo}/contributors", options
374
373
  end
375
374
  alias :contribs :contributors
376
375
 
@@ -378,7 +377,7 @@ module Octokit
378
377
  #
379
378
  # Requires authenticated client for private repos.
380
379
  #
381
- # @param repo [String, Hash, Repository] A GitHub repository.
380
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
382
381
  # @return [Array<Sawyer::Resource>] Array of hashes representing users.
383
382
  # @see https://developer.github.com/v3/activity/starring/#list-stargazers
384
383
  # @example
@@ -386,7 +385,7 @@ module Octokit
386
385
  # @example
387
386
  # @client.stargazers('octokit/octokit.rb')
388
387
  def stargazers(repo, options = {})
389
- paginate "repos/#{Repository.new(repo)}/stargazers", options
388
+ paginate "#{Repository.path repo}/stargazers", options
390
389
  end
391
390
 
392
391
  # @deprecated Use {#stargazers} instead
@@ -395,7 +394,7 @@ module Octokit
395
394
  #
396
395
  # Requires authenticated client for private repos.
397
396
  #
398
- # @param repo [String, Hash, Repository] A GitHub repository.
397
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
399
398
  # @return [Array<Sawyer::Resource>] Array of hashes representing users.
400
399
  # @see https://developer.github.com/v3/repos/watching/#list-watchers
401
400
  # @example
@@ -403,14 +402,14 @@ module Octokit
403
402
  # @example
404
403
  # @client.watchers('octokit/octokit.rb')
405
404
  def watchers(repo, options = {})
406
- paginate "repos/#{Repository.new(repo)}/watchers", options
405
+ paginate "#{Repository.path repo}/watchers", options
407
406
  end
408
407
 
409
408
  # List forks
410
409
  #
411
410
  # Requires authenticated client for private repos.
412
411
  #
413
- # @param repo [String, Hash, Repository] A GitHub repository.
412
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
414
413
  # @return [Array<Sawyer::Resource>] Array of hashes representing repos.
415
414
  # @see https://developer.github.com/v3/repos/forks/#list-forks
416
415
  # @example
@@ -420,7 +419,7 @@ module Octokit
420
419
  # @example
421
420
  # @client.forks('octokit/octokit.rb')
422
421
  def forks(repo, options = {})
423
- paginate "repos/#{Repository.new(repo)}/forks", options
422
+ paginate "#{Repository.path repo}/forks", options
424
423
  end
425
424
  alias :network :forks
426
425
 
@@ -428,22 +427,22 @@ module Octokit
428
427
  #
429
428
  # Requires authenticated client for private repos.
430
429
  #
431
- # @param repo [String, Hash, Repository] A GitHub repository.
430
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
432
431
  # @return [Array<Sawyer::Resource>] Array of Hashes representing languages.
433
432
  # @see https://developer.github.com/v3/repos/#list-languages
434
433
  # @example
435
- # Octokit.langauges('octokit/octokit.rb')
434
+ # Octokit.languages('octokit/octokit.rb')
436
435
  # @example
437
436
  # @client.languages('octokit/octokit.rb')
438
437
  def languages(repo, options = {})
439
- paginate "repos/#{Repository.new(repo)}/languages", options
438
+ paginate "#{Repository.path repo}/languages", options
440
439
  end
441
440
 
442
441
  # List tags
443
442
  #
444
443
  # Requires authenticated client for private repos.
445
444
  #
446
- # @param repo [String, Hash, Repository] A GitHub repository.
445
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
447
446
  # @return [Array<Sawyer::Resource>] Array of hashes representing tags.
448
447
  # @see https://developer.github.com/v3/repos/#list-tags
449
448
  # @example
@@ -451,14 +450,14 @@ module Octokit
451
450
  # @example
452
451
  # @client.tags('octokit/octokit.rb')
453
452
  def tags(repo, options = {})
454
- paginate "repos/#{Repository.new(repo)}/tags", options
453
+ paginate "#{Repository.path repo}/tags", options
455
454
  end
456
455
 
457
456
  # List branches
458
457
  #
459
458
  # Requires authenticated client for private repos.
460
459
  #
461
- # @param repo [String, Hash, Repository] A GitHub repository.
460
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
462
461
  # @return [Array<Sawyer::Resource>] Array of hashes representing branches.
463
462
  # @see https://developer.github.com/v3/repos/#list-branches
464
463
  # @example
@@ -466,19 +465,19 @@ module Octokit
466
465
  # @example
467
466
  # @client.branches('octokit/octokit.rb')
468
467
  def branches(repo, options = {})
469
- paginate "repos/#{Repository.new(repo)}/branches", options
468
+ paginate "#{Repository.path repo}/branches", options
470
469
  end
471
470
 
472
471
  # Get a single branch from a repository
473
472
  #
474
- # @param repo [String, Hash, Repository] A GitHub repository.
473
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
475
474
  # @param branch [String] Branch name
476
475
  # @return [Sawyer::Resource] The branch requested, if it exists
477
476
  # @see https://developer.github.com/v3/repos/#get-branch
478
477
  # @example Get branch 'master` from octokit/octokit.rb
479
478
  # Octokit.branch("octokit/octokit.rb", "master")
480
479
  def branch(repo, branch, options = {})
481
- get "repos/#{Repository.new(repo)}/branches/#{branch}", options
480
+ get "#{Repository.path repo}/branches/#{branch}", options
482
481
  end
483
482
  alias :get_branch :branch
484
483
 
@@ -486,34 +485,34 @@ module Octokit
486
485
  #
487
486
  # Requires authenticated client.
488
487
  #
489
- # @param repo [String, Hash, Repository] A GitHub repository.
488
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
490
489
  # @return [Array<Sawyer::Resource>] Array of hashes representing hooks.
491
490
  # @see https://developer.github.com/v3/repos/hooks/#list-hooks
492
491
  # @example
493
492
  # @client.hooks('octokit/octokit.rb')
494
493
  def hooks(repo, options = {})
495
- paginate "repos/#{Repository.new(repo)}/hooks", options
494
+ paginate "#{Repository.path repo}/hooks", options
496
495
  end
497
496
 
498
497
  # Get single hook
499
498
  #
500
499
  # Requires authenticated client.
501
500
  #
502
- # @param repo [String, Hash, Repository] A GitHub repository.
501
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
503
502
  # @param id [Integer] Id of the hook to get.
504
503
  # @return [Sawyer::Resource] Hash representing hook.
505
504
  # @see https://developer.github.com/v3/repos/hooks/#get-single-hook
506
505
  # @example
507
506
  # @client.hook('octokit/octokit.rb', 100000)
508
507
  def hook(repo, id, options = {})
509
- get "repos/#{Repository.new(repo)}/hooks/#{id}", options
508
+ get "#{Repository.path repo}/hooks/#{id}", options
510
509
  end
511
510
 
512
511
  # Create a hook
513
512
  #
514
513
  # Requires authenticated client.
515
514
  #
516
- # @param repo [String, Hash, Repository] A GitHub repository.
515
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
517
516
  # @param name [String] The name of the service that is being called. See
518
517
  # {https://api.github.com/hooks Hooks} for the possible names.
519
518
  # @param config [Hash] A Hash containing key/value pairs to provide
@@ -542,14 +541,14 @@ module Octokit
542
541
  # )
543
542
  def create_hook(repo, name, config, options = {})
544
543
  options = {:name => name, :config => config, :events => ["push"], :active => true}.merge(options)
545
- post "repos/#{Repository.new(repo)}/hooks", options
544
+ post "#{Repository.path repo}/hooks", options
546
545
  end
547
546
 
548
547
  # Edit a hook
549
548
  #
550
549
  # Requires authenticated client.
551
550
  #
552
- # @param repo [String, Hash, Repository] A GitHub repository.
551
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
553
552
  # @param id [Integer] Id of the hook being updated.
554
553
  # @param name [String] The name of the service that is being called. See
555
554
  # {https://api.github.com/hooks Hooks} for the possible names.
@@ -585,42 +584,42 @@ module Octokit
585
584
  # )
586
585
  def edit_hook(repo, id, name, config, options = {})
587
586
  options = {:name => name, :config => config, :events => ["push"], :active => true}.merge(options)
588
- patch "repos/#{Repository.new(repo)}/hooks/#{id}", options
587
+ patch "#{Repository.path repo}/hooks/#{id}", options
589
588
  end
590
589
 
591
590
  # Delete hook
592
591
  #
593
592
  # Requires authenticated client.
594
593
  #
595
- # @param repo [String, Hash, Repository] A GitHub repository.
594
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
596
595
  # @param id [Integer] Id of the hook to remove.
597
596
  # @return [Boolean] True if hook removed, false otherwise.
598
597
  # @see https://developer.github.com/v3/repos/hooks/#delete-a-hook
599
598
  # @example
600
599
  # @client.remove_hook('octokit/octokit.rb', 1000000)
601
600
  def remove_hook(repo, id, options = {})
602
- boolean_from_response :delete, "repos/#{Repository.new(repo)}/hooks/#{id}", options
601
+ boolean_from_response :delete, "#{Repository.path repo}/hooks/#{id}", options
603
602
  end
604
603
 
605
604
  # Test hook
606
605
  #
607
606
  # Requires authenticated client.
608
607
  #
609
- # @param repo [String, Hash, Repository] A GitHub repository.
608
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
610
609
  # @param id [Integer] Id of the hook to test.
611
610
  # @return [Boolean] Success
612
611
  # @see https://developer.github.com/v3/repos/hooks/#test-a-push-hook
613
612
  # @example
614
613
  # @client.test_hook('octokit/octokit.rb', 1000000)
615
614
  def test_hook(repo, id, options = {})
616
- boolean_from_response :post, "repos/#{Repository.new(repo)}/hooks/#{id}/tests", options
615
+ boolean_from_response :post, "#{Repository.path repo}/hooks/#{id}/tests", options
617
616
  end
618
617
 
619
618
  # List users available for assigning to issues.
620
619
  #
621
620
  # Requires authenticated client for private repos.
622
621
  #
623
- # @param repo [String, Hash, Repository] A GitHub repository.
622
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
624
623
  # @return [Array<Sawyer::Resource>] Array of hashes representing users.
625
624
  # @see https://developer.github.com/v3/issues/assignees/#list-assignees
626
625
  # @example
@@ -630,47 +629,47 @@ module Octokit
630
629
  # @example
631
630
  # @client.repository_assignees('octokit/octokit.rb')
632
631
  def repository_assignees(repo, options = {})
633
- paginate "repos/#{Repository.new(repo)}/assignees", options
632
+ paginate "#{Repository.path repo}/assignees", options
634
633
  end
635
634
  alias :repo_assignees :repository_assignees
636
635
 
637
636
  # Check to see if a particular user is an assignee for a repository.
638
637
  #
639
- # @param repo [String, Hash, Repository] A GitHub repository.
638
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
640
639
  # @param assignee [String] User login to check
641
640
  # @return [Boolean] True if assignable on project, false otherwise.
642
641
  # @see https://developer.github.com/v3/issues/assignees/#check-assignee
643
642
  # @example
644
643
  # Octokit.check_assignee('octokit/octokit.rb', 'andrew')
645
644
  def check_assignee(repo, assignee, options = {})
646
- boolean_from_response :get, "repos/#{Repository.new(repo)}/assignees/#{assignee}", options
645
+ boolean_from_response :get, "#{Repository.path repo}/assignees/#{assignee}", options
647
646
  end
648
647
 
649
648
  # List watchers subscribing to notifications for a repo
650
649
  #
651
- # @param repo [String, Hash, Repository] A GitHub repository.
650
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
652
651
  # @return [Array<Sawyer::Resource>] Array of users watching.
653
652
  # @see https://developer.github.com/v3/activity/watching/#list-watchers
654
653
  # @example
655
654
  # @client.subscribers("octokit/octokit.rb")
656
655
  def subscribers(repo, options = {})
657
- paginate "repos/#{Repository.new(repo)}/subscribers", options
656
+ paginate "#{Repository.path repo}/subscribers", options
658
657
  end
659
658
 
660
659
  # Get a repository subscription
661
660
  #
662
- # @param repo [String, Hash, Repository] A GitHub repository.
661
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
663
662
  # @return [Sawyer::Resource] Repository subscription.
664
663
  # @see https://developer.github.com/v3/activity/watching/#get-a-repository-subscription
665
664
  # @example
666
665
  # @client.subscription("octokit/octokit.rb")
667
666
  def subscription(repo, options = {})
668
- get "repos/#{Repository.new(repo)}/subscription", options
667
+ get "#{Repository.path repo}/subscription", options
669
668
  end
670
669
 
671
670
  # Update repository subscription
672
671
  #
673
- # @param repo [String, Hash, Repository] A GitHub repository.
672
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
674
673
  # @param options [Hash]
675
674
  #
676
675
  # @option options [Boolean] :subscribed Determines if notifications
@@ -682,19 +681,19 @@ module Octokit
682
681
  # @example Subscribe to notifications for a repository
683
682
  # @client.update_subscription("octokit/octokit.rb", {subscribed: true})
684
683
  def update_subscription(repo, options = {})
685
- put "repos/#{Repository.new(repo)}/subscription", options
684
+ put "#{Repository.path repo}/subscription", options
686
685
  end
687
686
 
688
687
  # Delete a repository subscription
689
688
  #
690
- # @param repo [String, Hash, Repository] A GitHub repository.
689
+ # @param repo [Integer, String, Hash, Repository] A GitHub repository.
691
690
  # @return [Boolean] True if subscription deleted, false otherwise.
692
691
  # @see https://developer.github.com/v3/activity/watching/#delete-a-repository-subscription
693
692
  #
694
693
  # @example
695
694
  # @client.delete_subscription("octokit/octokit.rb")
696
695
  def delete_subscription(repo, options = {})
697
- boolean_from_response :delete, "repos/#{Repository.new(repo)}/subscription", options
696
+ boolean_from_response :delete, "#{Repository.path repo}/subscription", options
698
697
  end
699
698
  end
700
699
  end