octokit 4.9.0 → 4.10.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +51 -44
- data/lib/octokit/client/authorizations.rb +2 -2
- data/lib/octokit/client/issues.rb +1 -0
- data/lib/octokit/client/marketplace.rb +4 -8
- data/lib/octokit/client/pull_requests.rb +2 -0
- data/lib/octokit/client/repositories.rb +33 -0
- data/lib/octokit/client/repository_invitations.rb +0 -7
- data/lib/octokit/client/reviews.rb +64 -20
- data/lib/octokit/client/stats.rb +1 -0
- data/lib/octokit/client/statuses.rb +1 -1
- data/lib/octokit/default.rb +2 -1
- data/lib/octokit/enterprise_admin_client/admin_stats.rb +1 -1
- data/lib/octokit/enterprise_admin_client/license.rb +1 -1
- data/lib/octokit/enterprise_admin_client/orgs.rb +2 -2
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +1 -1
- data/lib/octokit/enterprise_admin_client/users.rb +12 -12
- data/lib/octokit/enterprise_management_console_client.rb +1 -1
- data/lib/octokit/enterprise_management_console_client/management_console.rb +1 -1
- data/lib/octokit/preview.rb +0 -2
- data/lib/octokit/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a460f667b29d977f38ccdc7c2c57d2460c599c70
|
4
|
+
data.tar.gz: edcff602f1d864efef9472b3245cc6f8f87fc09d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22491d526fdcaf97d1f5d910cac626ecbf19acc6729e43746743b4394bc46a7b923db762874400fdcecb65cdbe2ea6e7487ce3c66f5656d45c9409755a10dc2f
|
7
|
+
data.tar.gz: eedcea418fbc75dea800de3700d5dd48a62f1b2f47702b470ca1b1c4c3d564f8a4f2e5f58b8754f27a11aac64e0f8ddd5eea0e576ed2a046812d38ef532a73df
|
data/README.md
CHANGED
@@ -54,11 +54,12 @@ Most methods have positional arguments for required input and an options hash
|
|
54
54
|
for optional parameters, headers, or other options:
|
55
55
|
|
56
56
|
```ruby
|
57
|
+
client = Octokit::Client.new
|
58
|
+
|
57
59
|
# Fetch a README with Accept header for HTML format
|
58
|
-
|
60
|
+
client.readme 'al3x/sovereign', :accept => 'application/vnd.github.html'
|
59
61
|
```
|
60
62
|
|
61
|
-
|
62
63
|
[wrappers]: http://wynnnetherland.com/journal/what-makes-a-good-api-wrapper
|
63
64
|
[github-api]: http://developer.github.com
|
64
65
|
|
@@ -74,24 +75,15 @@ Install via Rubygems
|
|
74
75
|
|
75
76
|
### Making requests
|
76
77
|
|
77
|
-
[API methods][] are available as
|
78
|
-
configuration) or as client instance methods.
|
78
|
+
[API methods][] are available as client instance methods.
|
79
79
|
|
80
80
|
```ruby
|
81
81
|
# Provide authentication credentials
|
82
|
-
Octokit.
|
83
|
-
c.login = 'defunkt'
|
84
|
-
c.password = 'c0d3b4ssssss!'
|
85
|
-
end
|
82
|
+
client = Octokit::Client.new(:login => 'defunkt', :password => 'c0d3b4ssssss!')
|
86
83
|
|
87
|
-
#
|
88
|
-
Octokit.
|
89
|
-
```
|
90
|
-
or
|
84
|
+
# Set access_token instead of login and password if you use personal access token
|
85
|
+
# client = Octokit::Client.new(:access_token => '[personal_access_token]!')
|
91
86
|
|
92
|
-
```ruby
|
93
|
-
# Provide authentication credentials
|
94
|
-
client = Octokit::Client.new(:login => 'defunkt', :password => 'c0d3b4ssssss!')
|
95
87
|
# Fetch the current user
|
96
88
|
client.user
|
97
89
|
```
|
@@ -108,7 +100,6 @@ When passing additional parameters to GET based request use the following syntax
|
|
108
100
|
# Example: Get contents of a repository by ref
|
109
101
|
# https://api.github.com/repos/octokit/octokit.rb/contents/path/to/file.rb?ref=some-other-branch
|
110
102
|
client.contents('octokit/octokit.rb', path: 'path/to/file.rb', query: {ref: 'some-other-branch'})
|
111
|
-
|
112
103
|
```
|
113
104
|
|
114
105
|
[API methods]: http://octokit.github.io/octokit.rb/method_list.html
|
@@ -119,8 +110,10 @@ Most methods return a `Resource` object which provides dot notation and `[]`
|
|
119
110
|
access for fields returned in the API response.
|
120
111
|
|
121
112
|
```ruby
|
113
|
+
client = Octokit::Client.new
|
114
|
+
|
122
115
|
# Fetch a user
|
123
|
-
user =
|
116
|
+
user = client.user 'jbarnette'
|
124
117
|
puts user.name
|
125
118
|
# => "John Barnette"
|
126
119
|
puts user.fields
|
@@ -141,8 +134,8 @@ need access to the raw HTTP response headers. You can access the last HTTP
|
|
141
134
|
response with `Client#last_response`:
|
142
135
|
|
143
136
|
```ruby
|
144
|
-
user =
|
145
|
-
response =
|
137
|
+
user = client.user 'andrewpthorp'
|
138
|
+
response = client.last_response
|
146
139
|
etag = response.headers[:etag]
|
147
140
|
```
|
148
141
|
|
@@ -157,9 +150,7 @@ Using your GitHub username and password is the easiest way to get started
|
|
157
150
|
making authenticated requests:
|
158
151
|
|
159
152
|
```ruby
|
160
|
-
client = Octokit::Client.new
|
161
|
-
:login => 'defunkt',
|
162
|
-
:password => 'c0d3b4ssssss!'
|
153
|
+
client = Octokit::Client.new(:login => 'defunkt', :password => 'c0d3b4ssssss!')
|
163
154
|
|
164
155
|
user = client.user
|
165
156
|
user.login
|
@@ -194,9 +185,7 @@ You can [create access tokens through your GitHub Account Settings](https://help
|
|
194
185
|
or with a basic authenticated Octokit client:
|
195
186
|
|
196
187
|
```ruby
|
197
|
-
client = Octokit::Client.new
|
198
|
-
:login => 'defunkt',
|
199
|
-
:password => 'c0d3b4ssssss!'
|
188
|
+
client = Octokit::Client.new(:login => 'defunkt', :password => 'c0d3b4ssssss!')
|
200
189
|
|
201
190
|
client.create_authorization(:scopes => ["user"], :note => "Name of token")
|
202
191
|
# => <your new oauth token>
|
@@ -282,7 +271,7 @@ user = client.user 'defunkt'
|
|
282
271
|
Default results from the GitHub API are 30, if you wish to add more you must do so during Octokit configuration.
|
283
272
|
|
284
273
|
```ruby
|
285
|
-
|
274
|
+
Octokit::Client.new(access_token: "<your 40 char token>", per_page: 100)
|
286
275
|
```
|
287
276
|
|
288
277
|
## Pagination
|
@@ -293,8 +282,8 @@ previous, and last pages for you in the `Link` response header as [Hypermedia
|
|
293
282
|
link relations](#hypermedia-agent).
|
294
283
|
|
295
284
|
```ruby
|
296
|
-
issues =
|
297
|
-
issues.concat
|
285
|
+
issues = client.issues 'rails/rails'
|
286
|
+
issues.concat client.last_response.rels[:next].get.data
|
298
287
|
```
|
299
288
|
|
300
289
|
### Auto pagination
|
@@ -304,13 +293,21 @@ enabled, calls for paginated resources will fetch and concatenate the results
|
|
304
293
|
from every page into a single array:
|
305
294
|
|
306
295
|
```ruby
|
307
|
-
|
308
|
-
issues =
|
296
|
+
client.auto_paginate = true
|
297
|
+
issues = client.issues 'rails/rails'
|
309
298
|
issues.length
|
310
299
|
|
311
300
|
# => 702
|
312
301
|
```
|
313
302
|
|
303
|
+
You can also enable auto pagination for all Octokit client instances:
|
304
|
+
|
305
|
+
```ruby
|
306
|
+
Octokit.configure do |c|
|
307
|
+
c.auto_paginate = true
|
308
|
+
end
|
309
|
+
```
|
310
|
+
|
314
311
|
**Note:** While Octokit auto pagination will set the page size to the maximum
|
315
312
|
`100`, and seek to not overstep your rate limit, you probably want to use a
|
316
313
|
custom pattern for traversing large lists.
|
@@ -329,6 +326,7 @@ To interact with the "regular" GitHub.com APIs in GitHub Enterprise, simply conf
|
|
329
326
|
Octokit.configure do |c|
|
330
327
|
c.api_endpoint = "https://<hostname>/api/v3/"
|
331
328
|
end
|
329
|
+
|
332
330
|
client = Octokit::Client.new(:access_token => "<your 40 char token>")
|
333
331
|
```
|
334
332
|
|
@@ -337,16 +335,18 @@ client = Octokit::Client.new(:access_token => "<your 40 char token>")
|
|
337
335
|
The GitHub Enterprise Admin APIs are under a different client: `EnterpriseAdminClient`. You'll need to have an administrator account in order to use these APIs.
|
338
336
|
|
339
337
|
``` ruby
|
340
|
-
admin_client = Octokit::EnterpriseAdminClient.new
|
341
|
-
|
342
|
-
|
338
|
+
admin_client = Octokit::EnterpriseAdminClient.new(
|
339
|
+
:access_token => "<your 40 char token>",
|
340
|
+
:api_endpoint => "https://<hostname>/api/v3/"
|
341
|
+
)
|
343
342
|
|
344
343
|
# or
|
345
344
|
Octokit.configure do |c|
|
346
345
|
c.api_endpoint = "https://<hostname>/api/v3/"
|
347
346
|
c.access_token = "<your 40 char token>"
|
348
347
|
end
|
349
|
-
|
348
|
+
|
349
|
+
admin_client = Octokit.enterprise_admin_client.new
|
350
350
|
```
|
351
351
|
|
352
352
|
### Interacting with the GitHub Enterprise Management Console APIs
|
@@ -354,15 +354,18 @@ admin_client = Octokit.enterprise_admin_client
|
|
354
354
|
The GitHub Enterprise Management Console APIs are also under a separate client: `EnterpriseManagementConsoleClient`. In order to use it, you'll need to provide both your management console password as well as the endpoint to your management console. This is different than the API endpoint provided above.
|
355
355
|
|
356
356
|
``` ruby
|
357
|
-
management_console_client = Octokit::EnterpriseManagementConsoleClient.new
|
358
|
-
|
359
|
-
|
357
|
+
management_console_client = Octokit::EnterpriseManagementConsoleClient.new(
|
358
|
+
:management_console_password => "secret",
|
359
|
+
:management_console_endpoint = "https://hostname:8633"
|
360
|
+
)
|
361
|
+
|
360
362
|
# or
|
361
363
|
Octokit.configure do |c|
|
362
364
|
c.management_console_endpoint = "https://hostname:8633"
|
363
365
|
c.management_console_password = "secret"
|
364
366
|
end
|
365
|
-
|
367
|
+
|
368
|
+
management_console_client = Octokit.enterprise_management_console_client.new
|
366
369
|
```
|
367
370
|
|
368
371
|
### SSL Connection Errors
|
@@ -410,7 +413,7 @@ Octokit's default.
|
|
410
413
|
|
411
414
|
```ruby
|
412
415
|
# Given $OCTOKIT_API_ENDPOINT is "http://api.github.dev"
|
413
|
-
|
416
|
+
client.api_endpoint
|
414
417
|
|
415
418
|
# => "http://api.github.dev"
|
416
419
|
```
|
@@ -430,7 +433,7 @@ Resources returned by Octokit methods contain not only data but hypermedia
|
|
430
433
|
link relations:
|
431
434
|
|
432
435
|
```ruby
|
433
|
-
user =
|
436
|
+
user = client.user 'technoweenie'
|
434
437
|
|
435
438
|
# Get the repos rel, returned from the API
|
436
439
|
# as repos_url in the resource
|
@@ -451,7 +454,7 @@ You might notice many link relations have variable placeholders. Octokit
|
|
451
454
|
supports [URI Templates][uri-templates] for parameterized URI expansion:
|
452
455
|
|
453
456
|
```ruby
|
454
|
-
repo =
|
457
|
+
repo = client.repo 'pengwynn/pingwynn'
|
455
458
|
rel = repo.rels[:issues]
|
456
459
|
# => #<Sawyer::Relation: issues: get https://api.github.com/repos/pengwynn/pingwynn/issues{/number}>
|
457
460
|
|
@@ -468,7 +471,7 @@ If you want to use Octokit as a pure hypermedia API client, you can start at
|
|
468
471
|
the API root and follow link relations from there:
|
469
472
|
|
470
473
|
```ruby
|
471
|
-
root =
|
474
|
+
root = client.root
|
472
475
|
root.rels[:repository].get :uri => {:owner => "octokit", :repo => "octokit.rb" }
|
473
476
|
root.rels[:user_repositories].get :uri => { :user => "octokit" },
|
474
477
|
:query => { :type => "owner" }
|
@@ -508,7 +511,7 @@ Octokit.default_media_type = "application/vnd.github.beta+json"
|
|
508
511
|
or per-request
|
509
512
|
|
510
513
|
```ruby
|
511
|
-
|
514
|
+
client.emails(:accept => "application/vnd.github.beta+json")
|
512
515
|
```
|
513
516
|
|
514
517
|
The long-deprecated `Octokit::Client#create_download` method has been removed.
|
@@ -549,6 +552,7 @@ traffic:
|
|
549
552
|
|
550
553
|
```ruby
|
551
554
|
stack = Faraday::RackBuilder.new do |builder|
|
555
|
+
builder.use Faraday::Request::Retry, exceptions: [Octokit::ServerError]
|
552
556
|
builder.use Octokit::Middleware::FollowRedirects
|
553
557
|
builder.use Octokit::Response::RaiseError
|
554
558
|
builder.use Octokit::Response::FeedParser
|
@@ -556,7 +560,9 @@ stack = Faraday::RackBuilder.new do |builder|
|
|
556
560
|
builder.adapter Faraday.default_adapter
|
557
561
|
end
|
558
562
|
Octokit.middleware = stack
|
559
|
-
|
563
|
+
|
564
|
+
client = Octokit::Client.new
|
565
|
+
client.user 'pengwynn'
|
560
566
|
```
|
561
567
|
```
|
562
568
|
I, [2013-08-22T15:54:38.583300 #88227] INFO -- : get https://api.github.com/users/pengwynn
|
@@ -681,6 +687,7 @@ implementations:
|
|
681
687
|
* Ruby 2.2
|
682
688
|
* Ruby 2.3
|
683
689
|
* Ruby 2.4
|
690
|
+
* Ruby 2.5
|
684
691
|
|
685
692
|
If something doesn't work on one of these Ruby versions, it's a bug.
|
686
693
|
|
@@ -231,11 +231,11 @@ module Octokit
|
|
231
231
|
if app_id.to_s.empty?
|
232
232
|
raise Octokit::ApplicationCredentialsRequired.new "client_id required"
|
233
233
|
end
|
234
|
-
authorize_url =
|
234
|
+
authorize_url = opts.delete(:endpoint) || Octokit.web_endpoint
|
235
235
|
authorize_url << "login/oauth/authorize?client_id=#{app_id}"
|
236
236
|
|
237
237
|
require 'cgi'
|
238
|
-
|
238
|
+
opts.each do |key, value|
|
239
239
|
authorize_url << "&#{key}=#{CGI.escape value}"
|
240
240
|
end
|
241
241
|
|
@@ -335,6 +335,7 @@ module Octokit
|
|
335
335
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
336
336
|
# @param number [Integer] Issue number
|
337
337
|
# @param assignees [Array] Assignees to be removed
|
338
|
+
# @param options [Hash] Header params for request
|
338
339
|
# @return [Sawyer::Resource] Issue
|
339
340
|
# @see https://developer.github.com/v3/issues/assignees/#remove-assignees-from-an-issue
|
340
341
|
# @example Remove assignees "pengwynn" and "joeyw" from Issue #23 on octokit/octokit.rb
|
@@ -14,8 +14,7 @@ module Octokit
|
|
14
14
|
#
|
15
15
|
# @return [Array<Sawyer::Resource>] A list of plans
|
16
16
|
def list_plans(options = {})
|
17
|
-
|
18
|
-
paginate "/marketplace_listing/plans", opts
|
17
|
+
paginate "/marketplace_listing/plans", options
|
19
18
|
end
|
20
19
|
|
21
20
|
# List all GitHub accounts on a specific plan
|
@@ -27,8 +26,7 @@ module Octokit
|
|
27
26
|
#
|
28
27
|
# @return [Array<Sawyer::Resource>] A list of accounts
|
29
28
|
def list_accounts_for_plan(plan_id, options = {})
|
30
|
-
|
31
|
-
paginate "/marketplace_listing/plans/#{plan_id}/accounts", opts
|
29
|
+
paginate "/marketplace_listing/plans/#{plan_id}/accounts", options
|
32
30
|
end
|
33
31
|
|
34
32
|
# Get the plan associated with a given GitHub account
|
@@ -40,8 +38,7 @@ module Octokit
|
|
40
38
|
#
|
41
39
|
# @return <Sawyer::Resource> Account with plan details, or nil
|
42
40
|
def plan_for_account(account_id, options = {})
|
43
|
-
|
44
|
-
get "/marketplace_listing/accounts/#{account_id}", opts
|
41
|
+
get "/marketplace_listing/accounts/#{account_id}", options
|
45
42
|
end
|
46
43
|
|
47
44
|
# Get user's Marketplace purchases
|
@@ -52,8 +49,7 @@ module Octokit
|
|
52
49
|
#
|
53
50
|
# @return [Array<Sawyer::Resource>] A list of Marketplace purchases
|
54
51
|
def marketplace_purchases(options = {})
|
55
|
-
|
56
|
-
get "/user/marketplace_purchases", opts
|
52
|
+
get "/user/marketplace_purchases", options
|
57
53
|
end
|
58
54
|
end
|
59
55
|
end
|
@@ -27,6 +27,8 @@ module Octokit
|
|
27
27
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
28
28
|
# @param number [Integer] Number of the pull request to fetch
|
29
29
|
# @return [Sawyer::Resource] Pull request info
|
30
|
+
# @example
|
31
|
+
# Octokit.pull_request('rails/rails', 42, :state => 'closed')
|
30
32
|
def pull_request(repo, number, options = {})
|
31
33
|
get "#{Repository.path repo}/pulls/#{number}", options
|
32
34
|
end
|
@@ -380,6 +380,39 @@ module Octokit
|
|
380
380
|
alias :repo_teams :repository_teams
|
381
381
|
alias :teams :repository_teams
|
382
382
|
|
383
|
+
# List all topics for a repository
|
384
|
+
#
|
385
|
+
# Requires authenticated client for private repos.
|
386
|
+
#
|
387
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository.
|
388
|
+
# @return [Sawyer::Resource] representing the topics for given repo
|
389
|
+
# @see https://developer.github.com/v3/repos/#list-all-topics-for-a-repository
|
390
|
+
# @example List topics for octokit/octokit.rb
|
391
|
+
# Octokit.topics('octokit/octokit.rb')
|
392
|
+
# @example List topics for octokit/octokit.rb
|
393
|
+
# client.topics('octokit/octokit.rb')
|
394
|
+
def topics(repo, options = {})
|
395
|
+
opts = ensure_api_media_type(:topics, options)
|
396
|
+
paginate "#{Repository.path repo}/topics", opts
|
397
|
+
end
|
398
|
+
|
399
|
+
# Replace all topics for a repository
|
400
|
+
#
|
401
|
+
# Requires authenticated client.
|
402
|
+
#
|
403
|
+
# @param repo [Integer, String, Repository, Hash] A Github repository
|
404
|
+
# @param names [Array] An array of topics to add to the repository.
|
405
|
+
# @return [Sawyer::Resource] representing the replaced topics for given repo
|
406
|
+
# @see https://developer.github.com/v3/repos/#replace-all-topics-for-a-repository
|
407
|
+
# @example Replace topics for octokit/octokit.rb
|
408
|
+
# client.replace_all_topics('octokit/octokit.rb', ['octocat', 'atom', 'electron', 'API'])
|
409
|
+
# @example Clear all topics for octokit/octokit.rb
|
410
|
+
# client.replace_all_topics('octokit/octokit.rb', [])
|
411
|
+
def replace_all_topics(repo, names, options = {})
|
412
|
+
opts = ensure_api_media_type(:topics, options)
|
413
|
+
put "#{Repository.path repo}/topics", opts.merge(:names => names)
|
414
|
+
end
|
415
|
+
|
383
416
|
# List contributors to a repo
|
384
417
|
#
|
385
418
|
# Requires authenticated client for private repos.
|
@@ -15,7 +15,6 @@ module Octokit
|
|
15
15
|
# @return [Sawyer::Resource] The repository invitation
|
16
16
|
# @see https://developer.github.com/v3/repos/invitations/#invite-a-user-to-a-repository
|
17
17
|
def invite_user_to_repository(repo, user, options = {})
|
18
|
-
options = ensure_api_media_type(:repository_invitations, options)
|
19
18
|
put "#{Repository.path repo}/collaborators/#{user}", options
|
20
19
|
end
|
21
20
|
alias invite_user_to_repo invite_user_to_repository
|
@@ -28,7 +27,6 @@ module Octokit
|
|
28
27
|
# @return [Array<Sawyer::Resource>] A list of invitations
|
29
28
|
# @see https://developer.github.com/v3/repos/invitations/#list-invitations-for-a-repository
|
30
29
|
def repository_invitations(repo, options = {})
|
31
|
-
options = ensure_api_media_type(:repository_invitations, options)
|
32
30
|
paginate "#{Repository.path repo}/invitations", options
|
33
31
|
end
|
34
32
|
alias repo_invitations repository_invitations
|
@@ -42,7 +40,6 @@ module Octokit
|
|
42
40
|
# @return [Boolean] True if the invitation was successfully deleted
|
43
41
|
# @see https://developer.github.com/v3/repos/invitations/#delete-a-repository-invitation
|
44
42
|
def delete_repository_invitation(repo, invitation_id, options = {})
|
45
|
-
options = ensure_api_media_type(:repository_invitations, options)
|
46
43
|
boolean_from_response :delete, "#{Repository.path repo}/invitations/#{invitation_id}", options
|
47
44
|
end
|
48
45
|
alias delete_repo_invitation delete_repository_invitation
|
@@ -56,7 +53,6 @@ module Octokit
|
|
56
53
|
# @return [Sawyer::Resource] The updated repository invitation
|
57
54
|
# @see https://developer.github.com/v3/repos/invitations/#update-a-repository-invitation
|
58
55
|
def update_repository_invitation(repo, invitation_id, options = {})
|
59
|
-
options = ensure_api_media_type(:repository_invitations, options)
|
60
56
|
patch "#{Repository.path repo}/invitations/#{invitation_id}", options
|
61
57
|
end
|
62
58
|
alias update_repo_invitation update_repository_invitation
|
@@ -68,7 +64,6 @@ module Octokit
|
|
68
64
|
# @return [Array<Sawyer::Resource>] The users repository invitations
|
69
65
|
# @see https://developer.github.com/v3/repos/invitations/#list-a-users-repository-invitations
|
70
66
|
def user_repository_invitations(options = {})
|
71
|
-
options = ensure_api_media_type(:repository_invitations, options)
|
72
67
|
paginate "/user/repository_invitations", options
|
73
68
|
end
|
74
69
|
alias user_repo_invitations user_repository_invitations
|
@@ -81,7 +76,6 @@ module Octokit
|
|
81
76
|
# @return [Boolean] True if the acceptance of the invitation was successful
|
82
77
|
# @see https://developer.github.com/v3/repos/invitations/#accept-a-repository-invitation
|
83
78
|
def accept_repository_invitation(invitation_id, options = {})
|
84
|
-
options = ensure_api_media_type(:repository_invitations, options)
|
85
79
|
patch "/user/repository_invitations/#{invitation_id}", options
|
86
80
|
end
|
87
81
|
alias accept_repo_invitation accept_repository_invitation
|
@@ -94,7 +88,6 @@ module Octokit
|
|
94
88
|
# @return [Boolean] True if the acceptance of the invitation was successful
|
95
89
|
# @see https://developer.github.com/v3/repos/invitations/#decline-a-repository-invitation
|
96
90
|
def decline_repository_invitation(invitation_id, options = {})
|
97
|
-
options = ensure_api_media_type(:repository_invitations, options)
|
98
91
|
boolean_from_response :delete, "/user/repository_invitations/#{invitation_id}", options
|
99
92
|
end
|
100
93
|
alias decline_invitation decline_repository_invitation
|
@@ -9,21 +9,21 @@ module Octokit
|
|
9
9
|
# List reviews on a pull request
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
12
|
-
# @param
|
12
|
+
# @param number [Integer] Number ID of the pull request
|
13
13
|
# @see https://developer.github.com/v3/pulls/reviews/#list-reviews-on-a-pull-request
|
14
14
|
#
|
15
15
|
# @example
|
16
16
|
# @client.pull_request_reviews('octokit/octokit.rb', 2)
|
17
17
|
#
|
18
18
|
# @return [Array<Sawyer::Resource>] Array of Hashes representing the reviews
|
19
|
-
def pull_request_reviews(repo,
|
20
|
-
paginate "#{Repository.path repo}/pulls/#{
|
19
|
+
def pull_request_reviews(repo, number, options = {})
|
20
|
+
paginate "#{Repository.path repo}/pulls/#{number}/reviews", options
|
21
21
|
end
|
22
22
|
|
23
23
|
# Get a single review
|
24
24
|
#
|
25
25
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
26
|
-
# @param number [Integer]
|
26
|
+
# @param number [Integer] Number ID of the pull request
|
27
27
|
# @param review [Integer] The id of the review
|
28
28
|
# @see https://developer.github.com/v3/pulls/reviews/#get-a-single-review
|
29
29
|
#
|
@@ -38,7 +38,7 @@ module Octokit
|
|
38
38
|
# Delete a pending review
|
39
39
|
#
|
40
40
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
41
|
-
# @param number [Integer]
|
41
|
+
# @param number [Integer] Number ID of the pull request
|
42
42
|
# @param review [Integer] The id of the review
|
43
43
|
# @see https://developer.github.com/v3/pulls/reviews/#delete-a-pending-review
|
44
44
|
#
|
@@ -53,7 +53,7 @@ module Octokit
|
|
53
53
|
# Get comments for a single review
|
54
54
|
#
|
55
55
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
56
|
-
# @param number [Integer]
|
56
|
+
# @param number [Integer] Number ID of the pull request
|
57
57
|
# @param review [Integer] The id of the review
|
58
58
|
# @see https://developer.github.com/v3/pulls/reviews/#get-comments-for-a-single-review
|
59
59
|
#
|
@@ -68,7 +68,7 @@ module Octokit
|
|
68
68
|
# Create a pull request review
|
69
69
|
#
|
70
70
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
71
|
-
# @param
|
71
|
+
# @param number [Integer] Number ID of the pull request
|
72
72
|
# @param options [Hash] Method options
|
73
73
|
# @option options [String] :event The review action (event) to perform;
|
74
74
|
# can be one of APPROVE, REQUEST_CHANGES, or COMMENT.
|
@@ -89,14 +89,14 @@ module Octokit
|
|
89
89
|
# @client.create_pull_request_review('octokit/octokit.rb', 844, options)
|
90
90
|
#
|
91
91
|
# @return [Sawyer::Resource>] Hash respresenting the review
|
92
|
-
def create_pull_request_review(repo,
|
93
|
-
post "#{Repository.path repo}/pulls/#{
|
92
|
+
def create_pull_request_review(repo, number, options = {})
|
93
|
+
post "#{Repository.path repo}/pulls/#{number}/reviews", options
|
94
94
|
end
|
95
95
|
|
96
96
|
# Submit a pull request review
|
97
97
|
#
|
98
98
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
99
|
-
# @param number [Integer]
|
99
|
+
# @param number [Integer] Number ID of the pull request
|
100
100
|
# @param review [Integer] The id of the review
|
101
101
|
# @param event [String] The review action (event) to perform; can be one of
|
102
102
|
# APPROVE, REQUEST_CHANGES, or COMMENT.
|
@@ -117,7 +117,7 @@ module Octokit
|
|
117
117
|
# Dismiss a pull request review
|
118
118
|
#
|
119
119
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
120
|
-
# @param number [Integer]
|
120
|
+
# @param number [Integer] Number ID of the pull request
|
121
121
|
# @param review [Integer] The id of the review
|
122
122
|
# @param message [String] The message for the pull request review dismissal
|
123
123
|
# @see https://developer.github.com/v3/pulls/reviews/#dismiss-a-pull-request-review
|
@@ -134,31 +134,75 @@ module Octokit
|
|
134
134
|
# List review requests
|
135
135
|
#
|
136
136
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
137
|
-
# @param
|
137
|
+
# @param number [Integer] Number ID of the pull request
|
138
138
|
# @see https://developer.github.com/v3/pulls/review_requests/#list-review-requests
|
139
139
|
#
|
140
140
|
# @example
|
141
141
|
# @client.pull_request_review_requests('octokit/octokit.rb', 2)
|
142
142
|
#
|
143
143
|
# @return [Array<Sawyer::Resource>] Array of Hashes representing the review requests
|
144
|
-
def pull_request_review_requests(repo,
|
145
|
-
paginate "#{Repository.path repo}/pulls/#{
|
144
|
+
def pull_request_review_requests(repo, number, options = {})
|
145
|
+
paginate "#{Repository.path repo}/pulls/#{number}/requested_reviewers", options
|
146
146
|
end
|
147
147
|
|
148
148
|
# Create a review request
|
149
149
|
#
|
150
150
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
151
|
-
# @param
|
152
|
-
# @param reviewers [Array<String>] An array of user logins
|
151
|
+
# @param number [Integer] Number ID of the pull request
|
152
|
+
# @param options [Hash] :reviewers [Array<String>] An array of user logins
|
153
|
+
# @param options [Hash] :team_reviewers [Array<String>] An array of team slugs
|
153
154
|
# @see https://developer.github.com/v3/pulls/review_requests/#create-a-review-request
|
154
155
|
#
|
155
156
|
# @example
|
156
|
-
# @client.request_pull_request_review('octokit/octokit.rb', 2, ['soudy'])
|
157
|
+
# @client.request_pull_request_review('octokit/octokit.rb', 2, reviewers: ['soudy'])
|
157
158
|
#
|
158
159
|
# @return [Sawyer::Resource>] Hash respresenting the pull request
|
159
|
-
def request_pull_request_review(repo,
|
160
|
-
|
161
|
-
|
160
|
+
def request_pull_request_review(repo, number, reviewers = {}, options = {})
|
161
|
+
# TODO(5.0): remove deprecated behavior
|
162
|
+
if reviewers.is_a?(Array)
|
163
|
+
octokit_warn(
|
164
|
+
"Deprecated: Octokit::Client#request_pull_request_review "\
|
165
|
+
"no longer takes a separate :reviewers argument.\n" \
|
166
|
+
"Please update your call to pass :reviewers and :team_reviewers as part of the options hash."
|
167
|
+
)
|
168
|
+
options = options.merge(reviewers: reviewers)
|
169
|
+
else
|
170
|
+
options = options.merge(reviewers)
|
171
|
+
end
|
172
|
+
|
173
|
+
post "#{Repository.path repo}/pulls/#{number}/requested_reviewers", options
|
174
|
+
end
|
175
|
+
|
176
|
+
# Delete a review request
|
177
|
+
#
|
178
|
+
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
179
|
+
# @param id [Integer] The id of the pull request
|
180
|
+
# @param options [Hash] :reviewers [Array] An array of user logins
|
181
|
+
# @param options [Hash] :team_reviewers [Array] An array of team slugs
|
182
|
+
#
|
183
|
+
# @see https://developer.github.com/v3/pulls/review_requests/#delete-a-review-request
|
184
|
+
#
|
185
|
+
# @example
|
186
|
+
# options = {
|
187
|
+
# "reviewers" => [ "octocat", "hubot", "other_user" ],
|
188
|
+
# "team_reviewers" => [ "justice-league" ]
|
189
|
+
# }
|
190
|
+
# @client.delete_pull_request_review_request('octokit/octokit.rb', 2, options)
|
191
|
+
#
|
192
|
+
# @return [Sawyer::Resource>] Hash representing the pull request
|
193
|
+
def delete_pull_request_review_request(repo, id, reviewers={}, options = {})
|
194
|
+
# TODO(5.0): remove deprecated behavior
|
195
|
+
if !reviewers.empty? && !options.empty?
|
196
|
+
octokit_warn(
|
197
|
+
"Deprecated: Octokit::Client#delete_pull_request_review_request "\
|
198
|
+
"no longer takes a separate :reviewers argument.\n" \
|
199
|
+
"Please update your call to pass :reviewers and :team_reviewers as part of the options hash."
|
200
|
+
)
|
201
|
+
end
|
202
|
+
# For backwards compatibility, this endpoint can be called with a separate reviewers hash.
|
203
|
+
# If not called with a separate hash, then 'reviewers' is, in fact, 'options'.
|
204
|
+
options = options.merge(reviewers)
|
205
|
+
delete "#{Repository.path repo}/pulls/#{id}/requested_reviewers", options
|
162
206
|
end
|
163
207
|
end
|
164
208
|
end
|
data/lib/octokit/client/stats.rb
CHANGED
@@ -96,6 +96,7 @@ module Octokit
|
|
96
96
|
loop do
|
97
97
|
data = get("#{Repository.path repo}/stats/#{metric}", options)
|
98
98
|
return data if last_response.status == 200
|
99
|
+
return [] if last_response.status == 204
|
99
100
|
return nil unless retry_timeout
|
100
101
|
return nil if Time.now >= timeout
|
101
102
|
sleep retry_wait if retry_wait
|
@@ -13,7 +13,7 @@ module Octokit
|
|
13
13
|
# @return [Array<Sawyer::Resource>] A list of statuses
|
14
14
|
# @see https://developer.github.com/v3/repos/statuses/#list-statuses-for-a-specific-ref
|
15
15
|
def statuses(repo, sha, options = {})
|
16
|
-
|
16
|
+
paginate "#{Repository.path repo}/statuses/#{sha}", options
|
17
17
|
end
|
18
18
|
alias :list_statuses :statuses
|
19
19
|
|
data/lib/octokit/default.rb
CHANGED
@@ -25,6 +25,7 @@ module Octokit
|
|
25
25
|
|
26
26
|
# Default Faraday middleware stack
|
27
27
|
MIDDLEWARE = RACK_BUILDER_CLASS.new do |builder|
|
28
|
+
builder.use Faraday::Request::Retry, exceptions: [Octokit::ServerError]
|
28
29
|
builder.use Octokit::Middleware::FollowRedirects
|
29
30
|
builder.use Octokit::Response::RaiseError
|
30
31
|
builder.use Octokit::Response::FeedParser
|
@@ -143,7 +144,7 @@ module Octokit
|
|
143
144
|
# 0 is OpenSSL::SSL::VERIFY_NONE
|
144
145
|
# 1 is OpenSSL::SSL::SSL_VERIFY_PEER
|
145
146
|
# the standard default for SSL is SSL_VERIFY_PEER which requires a server certificate check on the client
|
146
|
-
ENV
|
147
|
+
ENV.fetch('OCTOKIT_SSL_VERIFY_MODE', 1).to_i
|
147
148
|
end
|
148
149
|
|
149
150
|
# Default User-Agent header string from ENV or {USER_AGENT}
|
@@ -3,7 +3,7 @@ module Octokit
|
|
3
3
|
|
4
4
|
# Methods for the Enterprise Orgs API
|
5
5
|
#
|
6
|
-
# @see https://developer.github.com/v3/enterprise/orgs/
|
6
|
+
# @see https://developer.github.com/v3/enterprise-admin/orgs/
|
7
7
|
module Orgs
|
8
8
|
|
9
9
|
# Create a new organization on the instance.
|
@@ -13,7 +13,7 @@ module Octokit
|
|
13
13
|
# @param options [Hash] A set of options.
|
14
14
|
# @option options [String] :profile_name The organization's display name.
|
15
15
|
# @return [nil]
|
16
|
-
# @see https://developer.github.com/v3/enterprise/orgs/#create-an-organization
|
16
|
+
# @see https://developer.github.com/v3/enterprise-admin/orgs/#create-an-organization
|
17
17
|
# @example
|
18
18
|
# @admin_client.create_organization('SuchAGreatOrg', 'gjtorikian')
|
19
19
|
def create_organization(login, admin, options = {})
|
@@ -3,7 +3,7 @@ module Octokit
|
|
3
3
|
|
4
4
|
# Methods for the Enterprise Search Indexing API
|
5
5
|
#
|
6
|
-
# @see https://developer.github.com/v3/enterprise/search_indexing/
|
6
|
+
# @see https://developer.github.com/v3/enterprise-admin/search_indexing/
|
7
7
|
module SearchIndexing
|
8
8
|
|
9
9
|
# Queue a User or Organization to be indexed
|
@@ -3,13 +3,13 @@ module Octokit
|
|
3
3
|
|
4
4
|
# Methods for the Enterprise User Administration API
|
5
5
|
#
|
6
|
-
# @see https://developer.github.com/v3/users/
|
6
|
+
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/
|
7
7
|
module Users
|
8
8
|
# Create a new user.
|
9
9
|
#
|
10
10
|
# @param login [String] The user's username.
|
11
11
|
# @param email [String] The user's email address.
|
12
|
-
# @see https://developer.github.com/v3/users
|
12
|
+
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users#create-a-new-user
|
13
13
|
# @example
|
14
14
|
# @admin_client.create_user('foobar', 'notreal@foo.bar')
|
15
15
|
def create_user(login, email, options = {})
|
@@ -22,7 +22,7 @@ module Octokit
|
|
22
22
|
#
|
23
23
|
# @param user [String] Username of the user to promote.
|
24
24
|
# @return [Boolean] True if promote was successful, false otherwise.
|
25
|
-
# @see https://developer.github.com/v3/users
|
25
|
+
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#promote-an-ordinary-user-to-a-site-administrator
|
26
26
|
# @example
|
27
27
|
# @admin_client.promote('holman')
|
28
28
|
def promote(user, options = {})
|
@@ -33,7 +33,7 @@ module Octokit
|
|
33
33
|
#
|
34
34
|
# @param user [String] Username of the user to demote.
|
35
35
|
# @return [Boolean] True if demote was successful, false otherwise.
|
36
|
-
# @see https://developer.github.com/v3/users
|
36
|
+
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#demote-a-site-administrator-to-an-ordinary-user
|
37
37
|
# @example
|
38
38
|
# @admin_client.demote('holman')
|
39
39
|
def demote(user, options = {})
|
@@ -44,7 +44,7 @@ module Octokit
|
|
44
44
|
#
|
45
45
|
# @param old_login [String] The user's old username.
|
46
46
|
# @param new_login [String] The user's new username.
|
47
|
-
# @see https://developer.github.com/v3/users
|
47
|
+
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#rename-an-existing-user
|
48
48
|
# @example
|
49
49
|
# @admin_client.rename_user('foobar', 'foofoobar')
|
50
50
|
def rename_user(old_login, new_login, options = {})
|
@@ -55,7 +55,7 @@ module Octokit
|
|
55
55
|
# Deletes a user.
|
56
56
|
#
|
57
57
|
# @param username [String] The username to delete.
|
58
|
-
# @see https://developer.github.com/v3/users
|
58
|
+
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#delete-a-user
|
59
59
|
# @example
|
60
60
|
# @admin_client.delete_key(1)
|
61
61
|
def delete_user(username, options = {})
|
@@ -66,7 +66,7 @@ module Octokit
|
|
66
66
|
#
|
67
67
|
# @param user [String] Username of the user to suspend.
|
68
68
|
# @return [Boolean] True if suspend was successful, false otherwise.
|
69
|
-
# @see https://developer.github.com/v3/users
|
69
|
+
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#suspend-a-user
|
70
70
|
# @example
|
71
71
|
# @admin_client.suspend('holman')
|
72
72
|
def suspend(user, options = {})
|
@@ -77,7 +77,7 @@ module Octokit
|
|
77
77
|
#
|
78
78
|
# @param user [String] Username of the user to unsuspend.
|
79
79
|
# @return [Boolean] True if unsuspend was successful, false otherwise.
|
80
|
-
# @see https://developer.github.com/v3/users
|
80
|
+
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#unsuspend-a-user
|
81
81
|
# @example
|
82
82
|
# @admin_client.unsuspend('holman')
|
83
83
|
def unsuspend(user, options = {})
|
@@ -88,7 +88,7 @@ module Octokit
|
|
88
88
|
#
|
89
89
|
# @param login [String] The user to create a token for.
|
90
90
|
# @param options [Array<String>] :scopes The scopes to apply.
|
91
|
-
# @see https://developer.github.com/v3/users
|
91
|
+
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#create-an-impersonation-oauth-token
|
92
92
|
# @example
|
93
93
|
# @admin_client.create_impersonation_token('foobar', {:scopes => ['repo:write']})
|
94
94
|
def create_impersonation_token(login, options = {})
|
@@ -98,7 +98,7 @@ module Octokit
|
|
98
98
|
# Deletes an impersonation OAuth token.
|
99
99
|
#
|
100
100
|
# @param login [String] The user whose token should be deleted.
|
101
|
-
# @see https://developer.github.com/v3/users
|
101
|
+
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#delete-an-impersonation-oauth-token
|
102
102
|
# @example
|
103
103
|
# @admin_client.delete_impersonation_token('foobar')
|
104
104
|
def delete_impersonation_token(login, options = {})
|
@@ -107,7 +107,7 @@ module Octokit
|
|
107
107
|
|
108
108
|
# Lists all the public SSH keys.
|
109
109
|
#
|
110
|
-
# @see https://developer.github.com/v3/users
|
110
|
+
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#list-all-public-keys
|
111
111
|
# @example
|
112
112
|
# @admin_client.list_all_keys
|
113
113
|
def list_all_keys(options = {})
|
@@ -117,7 +117,7 @@ module Octokit
|
|
117
117
|
# Deletes a public SSH keys.
|
118
118
|
#
|
119
119
|
# @param id [Number] The ID of the key to delete.
|
120
|
-
# @see https://developer.github.com/v3/users
|
120
|
+
# @see https://developer.github.com/enterprise/v3/enterprise-admin/users/#delete-a-public-key
|
121
121
|
# @example
|
122
122
|
# @admin_client.delete_key(1)
|
123
123
|
def delete_key(id, options = {})
|
@@ -10,7 +10,7 @@ module Octokit
|
|
10
10
|
#
|
11
11
|
# @see Octokit::Client Use Octokit::Client for regular API use for GitHub
|
12
12
|
# and GitHub Enterprise.
|
13
|
-
# @see https://developer.github.com/v3/enterprise/management_console/
|
13
|
+
# @see https://developer.github.com/v3/enterprise-admin/management_console/
|
14
14
|
class EnterpriseManagementConsoleClient
|
15
15
|
|
16
16
|
include Octokit::Configurable
|
@@ -3,7 +3,7 @@ module Octokit
|
|
3
3
|
|
4
4
|
# Methods for the Enterprise Management Console API
|
5
5
|
#
|
6
|
-
# @see https://developer.github.com/v3/enterprise/management_console
|
6
|
+
# @see https://developer.github.com/v3/enterprise-admin/management_console/
|
7
7
|
module ManagementConsole
|
8
8
|
|
9
9
|
# Uploads a license for the first time
|
data/lib/octokit/preview.rb
CHANGED
@@ -10,14 +10,12 @@ module Octokit
|
|
10
10
|
:licenses => 'application/vnd.github.drax-preview+json'.freeze,
|
11
11
|
:source_imports => 'application/vnd.github.barred-rock-preview'.freeze,
|
12
12
|
:reactions => 'application/vnd.github.squirrel-girl-preview'.freeze,
|
13
|
-
:repository_invitations => 'application/vnd.github.swamp-thing-preview+json'.freeze,
|
14
13
|
:issue_timelines => 'application/vnd.github.mockingbird-preview+json'.freeze,
|
15
14
|
:nested_teams => 'application/vnd.github.hellcat-preview+json'.freeze,
|
16
15
|
:pages => 'application/vnd.github.mister-fantastic-preview+json'.freeze,
|
17
16
|
:projects => 'application/vnd.github.inertia-preview+json'.freeze,
|
18
17
|
:traffic => 'application/vnd.github.spiderman-preview'.freeze,
|
19
18
|
:integrations => 'application/vnd.github.machine-man-preview+json'.freeze,
|
20
|
-
:marketplace => 'application/vnd.github.valkyrie-preview+json'.freeze,
|
21
19
|
:topics => 'application/vnd.github.mercy-preview+json'.freeze
|
22
20
|
}
|
23
21
|
|
data/lib/octokit/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octokit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.10.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wynn Netherland
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-08-09 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -153,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
153
153
|
version: 1.3.5
|
154
154
|
requirements: []
|
155
155
|
rubyforge_project:
|
156
|
-
rubygems_version: 2.5.2
|
156
|
+
rubygems_version: 2.5.2
|
157
157
|
signing_key:
|
158
158
|
specification_version: 4
|
159
159
|
summary: Ruby toolkit for working with the GitHub API
|