octokit 4.21.0 → 4.25.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 +90 -63
- data/Rakefile +5 -3
- data/lib/ext/sawyer/relation.rb +4 -2
- data/lib/octokit/arguments.rb +2 -2
- data/lib/octokit/authentication.rb +10 -3
- data/lib/octokit/client/actions_secrets.rb +2 -3
- data/lib/octokit/client/actions_workflow_runs.rb +2 -0
- data/lib/octokit/client/actions_workflows.rb +2 -1
- data/lib/octokit/client/apps.rb +26 -26
- data/lib/octokit/client/authorizations.rb +20 -17
- data/lib/octokit/client/checks.rb +18 -9
- data/lib/octokit/client/commit_branches.rb +2 -2
- data/lib/octokit/client/commit_comments.rb +8 -8
- data/lib/octokit/client/commit_pulls.rb +2 -2
- data/lib/octokit/client/commits.rb +31 -34
- data/lib/octokit/client/community_profile.rb +2 -2
- data/lib/octokit/client/contents.rb +20 -21
- data/lib/octokit/client/deployments.rb +6 -6
- data/lib/octokit/client/downloads.rb +5 -6
- data/lib/octokit/client/emojis.rb +3 -3
- data/lib/octokit/client/events.rb +4 -4
- data/lib/octokit/client/feeds.rb +4 -5
- data/lib/octokit/client/gists.rb +6 -6
- data/lib/octokit/client/gitignore.rb +3 -3
- data/lib/octokit/client/hooks.rb +10 -10
- data/lib/octokit/client/issues.rb +14 -14
- data/lib/octokit/client/labels.rb +10 -10
- data/lib/octokit/client/legacy_search.rb +3 -3
- data/lib/octokit/client/licenses.rb +3 -3
- data/lib/octokit/client/markdown.rb +3 -3
- data/lib/octokit/client/marketplace.rb +4 -4
- data/lib/octokit/client/meta.rb +4 -5
- data/lib/octokit/client/milestones.rb +5 -5
- data/lib/octokit/client/notifications.rb +6 -6
- data/lib/octokit/client/oauth_applications.rb +0 -2
- data/lib/octokit/client/objects.rb +14 -14
- data/lib/octokit/client/organizations.rb +48 -48
- data/lib/octokit/client/pages.rb +3 -3
- data/lib/octokit/client/projects.rb +18 -19
- data/lib/octokit/client/pub_sub_hubbub.rb +16 -16
- data/lib/octokit/client/pull_requests.rb +41 -42
- data/lib/octokit/client/rate_limit.rb +9 -11
- data/lib/octokit/client/reactions.rb +6 -6
- data/lib/octokit/client/refs.rb +14 -15
- data/lib/octokit/client/releases.rb +13 -13
- data/lib/octokit/client/repositories.rb +36 -36
- data/lib/octokit/client/repository_invitations.rb +3 -3
- data/lib/octokit/client/reviews.rb +7 -7
- data/lib/octokit/client/say.rb +4 -5
- data/lib/octokit/client/search.rb +9 -9
- data/lib/octokit/client/service_status.rb +19 -9
- data/lib/octokit/client/source_import.rb +6 -6
- data/lib/octokit/client/stats.rb +10 -9
- data/lib/octokit/client/statuses.rb +5 -5
- data/lib/octokit/client/traffic.rb +2 -3
- data/lib/octokit/client/users.rb +27 -26
- data/lib/octokit/client.rb +28 -14
- data/lib/octokit/configurable.rb +33 -27
- data/lib/octokit/connection.rb +22 -23
- data/lib/octokit/default.rb +30 -18
- data/lib/octokit/enterprise_admin_client/admin_stats.rb +13 -14
- data/lib/octokit/enterprise_admin_client/license.rb +3 -4
- data/lib/octokit/enterprise_admin_client/orgs.rb +3 -4
- data/lib/octokit/enterprise_admin_client/search_indexing.rb +7 -8
- data/lib/octokit/enterprise_admin_client/users.rb +5 -4
- data/lib/octokit/enterprise_admin_client.rb +9 -3
- data/lib/octokit/enterprise_management_console_client/management_console.rb +32 -32
- data/lib/octokit/enterprise_management_console_client.rb +8 -2
- data/lib/octokit/error.rb +27 -23
- data/lib/octokit/gist.rb +2 -3
- data/lib/octokit/middleware/follow_redirects.rb +15 -11
- data/lib/octokit/organization.rb +3 -1
- data/lib/octokit/preview.rb +29 -29
- data/lib/octokit/rate_limit.rb +3 -3
- data/lib/octokit/repo_arguments.rb +2 -3
- data/lib/octokit/repository.rb +23 -24
- data/lib/octokit/response/base_middleware.rb +10 -0
- data/lib/octokit/response/feed_parser.rb +5 -7
- data/lib/octokit/response/raise_error.rb +4 -4
- data/lib/octokit/user.rb +4 -2
- data/lib/octokit/version.rb +3 -1
- data/lib/octokit/warnable.rb +4 -5
- data/lib/octokit.rb +15 -8
- data/octokit.gemspec +11 -9
- metadata +19 -17
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4fb998f706df43131e06c214bd4db92440fe39efa77569b1e883f0a31a8fa8f4
|
4
|
+
data.tar.gz: 9ae3da4441db278a0a143b6d6cd38734beb6060ecc8339b002c483156da6069a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d01307c7c2a1ab08c1867ffcdbd26633c83844834345637acbde2dc794b02cf219181e3d90031beda91169812483a1637b3c2cf7af5028a01b03ce7b58d95785
|
7
|
+
data.tar.gz: 30da625ea0b0d89b1cc000ffee759fb3f8a4289940190281899a397c15dce692ebf3dced181b2a9e863ea7a118b7f23fefe491da8f1af0650c3e6d8856edd479
|
data/README.md
CHANGED
@@ -10,23 +10,25 @@ Upgrading? Check the [Upgrade Guide](#upgrading-guide) before bumping to a new
|
|
10
10
|
## Table of Contents
|
11
11
|
|
12
12
|
1. [Philosophy](#philosophy)
|
13
|
-
2. [
|
13
|
+
2. [Installation](#quick-start)
|
14
14
|
3. [Making requests](#making-requests)
|
15
|
+
1. [Additional Query Parameters](#additional-query-parameters)
|
15
16
|
4. [Consuming resources](#consuming-resources)
|
16
17
|
5. [Accessing HTTP responses](#accessing-http-responses)
|
17
|
-
6. [
|
18
|
+
6. [Handling errors](#handling-errors)
|
19
|
+
7. [Authentication](#authentication)
|
18
20
|
1. [Basic Authentication](#basic-authentication)
|
19
21
|
2. [OAuth access tokens](#oauth-access-tokens)
|
20
22
|
3. [Two-Factor Authentication](#two-factor-authentication)
|
21
23
|
4. [Using a .netrc file](#using-a-netrc-file)
|
22
24
|
5. [Application authentication](#application-authentication)
|
23
|
-
|
25
|
+
8. [Pagination](#pagination)
|
24
26
|
1. [Auto pagination](#auto-pagination)
|
25
|
-
|
27
|
+
9. [Working with GitHub Enterprise](#working-with-github-enterprise)
|
26
28
|
1. [Interacting with the GitHub.com APIs in GitHub Enterprise](#interacting-with-the-githubcom-apis-in-github-enterprise)
|
27
29
|
2. [Interacting with the GitHub Enterprise Admin APIs](#interacting-with-the-github-enterprise-admin-apis)
|
28
30
|
3. [Interacting with the GitHub Enterprise Management Console APIs](#interacting-with-the-github-enterprise-management-console-apis)
|
29
|
-
|
31
|
+
4. [SSL Connection Errors](#ssl-connection-errors)
|
30
32
|
10. [Configuration and defaults](#configuration-and-defaults)
|
31
33
|
1. [Configuring module defaults](#configuring-module-defaults)
|
32
34
|
2. [Using ENV variables](#using-env-variables)
|
@@ -66,7 +68,7 @@ client.readme 'al3x/sovereign', :accept => 'application/vnd.github.html'
|
|
66
68
|
[wrappers]: http://wynnnetherland.com/journal/what-makes-a-good-api-wrapper
|
67
69
|
[github-api]: https://developer.github.com/v3/
|
68
70
|
|
69
|
-
##
|
71
|
+
## Installation
|
70
72
|
|
71
73
|
Install via Rubygems
|
72
74
|
|
@@ -80,7 +82,7 @@ Access the library in Ruby:
|
|
80
82
|
|
81
83
|
require 'octokit'
|
82
84
|
|
83
|
-
|
85
|
+
## Making requests
|
84
86
|
|
85
87
|
[API methods][] are available as client instance methods.
|
86
88
|
|
@@ -95,7 +97,7 @@ client = Octokit::Client.new(:access_token => 'personal_access_token')
|
|
95
97
|
client.user
|
96
98
|
```
|
97
99
|
|
98
|
-
### Additional
|
100
|
+
### Additional query parameters
|
99
101
|
|
100
102
|
When passing additional parameters to GET based request use the following syntax:
|
101
103
|
|
@@ -109,9 +111,9 @@ When passing additional parameters to GET based request use the following syntax
|
|
109
111
|
client.contents('octokit/octokit.rb', path: 'path/to/file.rb', query: {ref: 'some-other-branch'})
|
110
112
|
```
|
111
113
|
|
112
|
-
[
|
114
|
+
[api methods]: http://octokit.github.io/octokit.rb/method_list.html
|
113
115
|
|
114
|
-
|
116
|
+
## Consuming resources
|
115
117
|
|
116
118
|
Most methods return a `Resource` object which provides dot notation and `[]`
|
117
119
|
access for fields returned in the API response.
|
@@ -134,7 +136,7 @@ user.rels[:gists].href
|
|
134
136
|
**Note:** URL fields are culled into a separate `.rels` collection for easier
|
135
137
|
[Hypermedia](#hypermedia-agent) support.
|
136
138
|
|
137
|
-
|
139
|
+
## Accessing HTTP responses
|
138
140
|
|
139
141
|
While most methods return a `Resource` object or a Boolean, sometimes you may
|
140
142
|
need access to the raw HTTP response headers. You can access the last HTTP
|
@@ -146,6 +148,23 @@ response = client.last_response
|
|
146
148
|
etag = response.headers[:etag]
|
147
149
|
```
|
148
150
|
|
151
|
+
## Handling errors
|
152
|
+
|
153
|
+
When the API returns an error response, Octokit will raise a Ruby exception.
|
154
|
+
|
155
|
+
A range of different exceptions can be raised depending on the error returned
|
156
|
+
by the API - for example:
|
157
|
+
|
158
|
+
* A `400 Bad Request` response will lead to an `Octokit::BadRequest` error
|
159
|
+
* A `403 Forbidden` error with a "rate limited exceeded" message will lead
|
160
|
+
to a `Octokit::TooManyRequests` error
|
161
|
+
|
162
|
+
All of the different exception classes inherit from `Octokit::Error` and
|
163
|
+
expose the `#response_status`, `#response_headers` and `#response_body`.
|
164
|
+
For validation errors, `#errors` will return an `Array` of `Hash`es
|
165
|
+
with the detailed information
|
166
|
+
[returned by the API](https://docs.github.com/en/rest/overview/resources-in-the-rest-api#client-errors).
|
167
|
+
|
149
168
|
## Authentication
|
150
169
|
|
151
170
|
Octokit supports the various [authentication methods supported by the GitHub
|
@@ -163,6 +182,7 @@ user = client.user
|
|
163
182
|
user.login
|
164
183
|
# => "defunkt"
|
165
184
|
```
|
185
|
+
|
166
186
|
While Basic Authentication allows you to get started quickly, OAuth access
|
167
187
|
tokens are the preferred way to authenticate on behalf of users.
|
168
188
|
|
@@ -171,9 +191,9 @@ tokens are the preferred way to authenticate on behalf of users.
|
|
171
191
|
[OAuth access tokens][oauth] provide two main benefits over using your username
|
172
192
|
and password:
|
173
193
|
|
174
|
-
|
194
|
+
- **Revocable access**. Access tokens can be revoked, removing access for only
|
175
195
|
that token without having to change your password everywhere.
|
176
|
-
|
196
|
+
- **Limited access**. Access tokens have [access scopes][] which allow for more
|
177
197
|
granular access to API resources. For instance, you can grant a third party
|
178
198
|
access to your gists but not your private repositories.
|
179
199
|
|
@@ -212,7 +232,7 @@ client = Octokit::Client.new \
|
|
212
232
|
user = client.user("defunkt", :headers => { "X-GitHub-OTP" => "<your 2FA token>" })
|
213
233
|
```
|
214
234
|
|
215
|
-
As you can imagine, this gets annoying
|
235
|
+
As you can imagine, this gets annoying quickly since two-factor auth tokens are very short lived. So it is recommended to create an oauth token for the user to communicate with the API:
|
216
236
|
|
217
237
|
```ruby
|
218
238
|
client = Octokit::Client.new \
|
@@ -227,13 +247,14 @@ client.create_authorization(:scopes => ["user"], :note => "Name of token",
|
|
227
247
|
### Using a .netrc file
|
228
248
|
|
229
249
|
Octokit supports reading credentials from a netrc file (defaulting to
|
230
|
-
`~/.netrc`).
|
250
|
+
`~/.netrc`). Given these lines in your netrc:
|
231
251
|
|
232
252
|
```
|
233
253
|
machine api.github.com
|
234
254
|
login defunkt
|
235
255
|
password c0d3b4ssssss!
|
236
256
|
```
|
257
|
+
|
237
258
|
You can now create a client with those credentials:
|
238
259
|
|
239
260
|
```ruby
|
@@ -241,6 +262,7 @@ client = Octokit::Client.new(:netrc => true)
|
|
241
262
|
client.login
|
242
263
|
# => "defunkt"
|
243
264
|
```
|
265
|
+
|
244
266
|
But _I want to use OAuth_ you say. Since the GitHub API supports using an OAuth
|
245
267
|
token as a Basic password, you totally can:
|
246
268
|
|
@@ -329,7 +351,7 @@ With a bit of setup, you can also use Octokit with your GitHub Enterprise instan
|
|
329
351
|
|
330
352
|
To interact with the "regular" GitHub.com APIs in GitHub Enterprise, simply configure the `api_endpoint` to match your hostname. For example:
|
331
353
|
|
332
|
-
```
|
354
|
+
```ruby
|
333
355
|
Octokit.configure do |c|
|
334
356
|
c.api_endpoint = "https://<hostname>/api/v3/"
|
335
357
|
end
|
@@ -341,7 +363,7 @@ client = Octokit::Client.new(:access_token => "<your 40 char token>")
|
|
341
363
|
|
342
364
|
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.
|
343
365
|
|
344
|
-
```
|
366
|
+
```ruby
|
345
367
|
admin_client = Octokit::EnterpriseAdminClient.new(
|
346
368
|
:access_token => "<your 40 char token>",
|
347
369
|
:api_endpoint => "https://<hostname>/api/v3/"
|
@@ -358,9 +380,9 @@ admin_client = Octokit.enterprise_admin_client.new
|
|
358
380
|
|
359
381
|
### Interacting with the GitHub Enterprise Management Console APIs
|
360
382
|
|
361
|
-
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
|
383
|
+
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 from the API endpoint provided above.
|
362
384
|
|
363
|
-
```
|
385
|
+
```ruby
|
364
386
|
management_console_client = Octokit::EnterpriseManagementConsoleClient.new(
|
365
387
|
:management_console_password => "secret",
|
366
388
|
:management_console_endpoint = "https://hostname:8633"
|
@@ -377,9 +399,9 @@ management_console_client = Octokit.enterprise_management_console_client.new
|
|
377
399
|
|
378
400
|
### SSL Connection Errors
|
379
401
|
|
380
|
-
You
|
402
|
+
You _may_ need to disable SSL temporarily while first setting up your GitHub Enterprise install. You can do that with the following configuration:
|
381
403
|
|
382
|
-
```
|
404
|
+
```ruby
|
383
405
|
client.connection_options[:ssl] = { :verify => false }
|
384
406
|
```
|
385
407
|
|
@@ -444,6 +466,7 @@ Octokit.configure do |c|
|
|
444
466
|
}
|
445
467
|
end
|
446
468
|
```
|
469
|
+
|
447
470
|
You should set a timeout in order to avoid Ruby’s Timeout module, which can hose your server. Here are some resources for more information on this:
|
448
471
|
|
449
472
|
- [The Oldest Bug In Ruby - Why Rack::Timeout Might Hose your Server](https://www.schneems.com/2017/02/21/the-oldest-bug-in-ruby-why-racktimeout-might-hose-your-server/)
|
@@ -473,7 +496,7 @@ repos.last.name
|
|
473
496
|
# => "faraday-zeromq"
|
474
497
|
```
|
475
498
|
|
476
|
-
When processing API responses, all `*_url` attributes are culled
|
499
|
+
When processing API responses, all `*_url` attributes are culled into the link
|
477
500
|
relations collection. Any `url` attribute becomes `.rels[:self]`.
|
478
501
|
|
479
502
|
### URI templates
|
@@ -509,8 +532,8 @@ Octokit 3.0 aims to be hypermedia-driven, removing the internal URL
|
|
509
532
|
construction currently used throughout the client.
|
510
533
|
|
511
534
|
[hypermedia]: http://en.wikipedia.org/wiki/Hypermedia
|
512
|
-
[
|
513
|
-
[
|
535
|
+
[sawyer]: https://github.com/lostisland/sawyer
|
536
|
+
[faraday]: https://github.com/lostisland/faraday
|
514
537
|
[uri-templates]: http://tools.ietf.org/html/rfc6570
|
515
538
|
|
516
539
|
## Upgrading guide
|
@@ -518,8 +541,8 @@ construction currently used throughout the client.
|
|
518
541
|
Version 4.0
|
519
542
|
|
520
543
|
- **removes support for a [long-deprecated overload][list-pulls] for
|
521
|
-
passing state as a positional argument** when listing pull requests. Instead,
|
522
|
-
pass `state` in the method options.
|
544
|
+
passing state as a positional argument** when listing pull requests. Instead,
|
545
|
+
pass `state` in the method options.
|
523
546
|
- **drops support for Ruby < 2.0**.
|
524
547
|
- adds support for new [Enterprise-only APIs](#working-with-github-enterprise).
|
525
548
|
- adds support for [Repository redirects][redirects].
|
@@ -536,6 +559,7 @@ for the client:
|
|
536
559
|
```ruby
|
537
560
|
Octokit.default_media_type = "application/vnd.github.beta+json"
|
538
561
|
```
|
562
|
+
|
539
563
|
or per-request
|
540
564
|
|
541
565
|
```ruby
|
@@ -552,21 +576,20 @@ Version 2.0 includes a completely rewritten `Client` factory that now memoizes
|
|
552
576
|
client instances based on unique configuration options. Breaking changes also
|
553
577
|
include:
|
554
578
|
|
555
|
-
|
556
|
-
|
557
|
-
|
579
|
+
- `:oauth_token` is now `:access_token`
|
580
|
+
- `:auto_traversal` is now `:auto_paginate`
|
581
|
+
- `Hashie::Mash` has been removed. Responses now return a `Sawyer::Resource`
|
558
582
|
object. This new type behaves mostly like a Ruby `Hash`, but does not fully
|
559
583
|
support the `Hashie::Mash` API.
|
560
|
-
|
584
|
+
- Two new client error types are raised where appropriate:
|
561
585
|
`Octokit::TooManyRequests` and `Octokit::TooManyLoginAttempts`
|
562
|
-
|
563
|
-
|
586
|
+
- The `search_*` methods from v1.x are now found at `legacy_search_*`
|
587
|
+
- Support for netrc requires including the [netrc gem][] in your Gemfile or
|
564
588
|
gemspec.
|
565
|
-
|
589
|
+
- DateTime fields are now proper `DateTime` objects. Previous versions outputted DateTime fields as 'String' objects.
|
566
590
|
|
567
591
|
[netrc gem]: https://rubygems.org/gems/netrc
|
568
592
|
|
569
|
-
|
570
593
|
## Advanced usage
|
571
594
|
|
572
595
|
Since Octokit employs [Faraday][faraday] under the hood, some behavior can be
|
@@ -580,11 +603,13 @@ traffic:
|
|
580
603
|
|
581
604
|
```ruby
|
582
605
|
stack = Faraday::RackBuilder.new do |builder|
|
583
|
-
builder.use Faraday::
|
606
|
+
builder.use Faraday::Retry::Middleware, exceptions: [Octokit::ServerError] # or Faraday::Request::Retry for Faraday < 2.0
|
584
607
|
builder.use Octokit::Middleware::FollowRedirects
|
585
608
|
builder.use Octokit::Response::RaiseError
|
586
609
|
builder.use Octokit::Response::FeedParser
|
587
|
-
builder.response :logger
|
610
|
+
builder.response :logger do |logger|
|
611
|
+
logger.filter(/(Authorization: "(token|Bearer) )(\w+)/, '\1[REMOVED]')
|
612
|
+
end
|
588
613
|
builder.adapter Faraday.default_adapter
|
589
614
|
end
|
590
615
|
Octokit.middleware = stack
|
@@ -592,6 +617,7 @@ Octokit.middleware = stack
|
|
592
617
|
client = Octokit::Client.new
|
593
618
|
client.user 'pengwynn'
|
594
619
|
```
|
620
|
+
|
595
621
|
```
|
596
622
|
I, [2013-08-22T15:54:38.583300 #88227] INFO -- : get https://api.github.com/users/pengwynn
|
597
623
|
D, [2013-08-22T15:54:38.583401 #88227] DEBUG -- request: Accept: "application/vnd.github.beta+json"
|
@@ -635,7 +661,6 @@ Once configured, the middleware will store responses in cache based on ETag
|
|
635
661
|
fingerprint and serve those back up for future `304` responses for the same
|
636
662
|
resource. See the [project README][cache] for advanced usage.
|
637
663
|
|
638
|
-
|
639
664
|
[cache]: https://github.com/plataformatec/faraday-http-cache
|
640
665
|
[faraday]: https://github.com/lostisland/faraday
|
641
666
|
|
@@ -651,12 +676,11 @@ to run a Ruby console to poke on Octokit, you can crank one up with:
|
|
651
676
|
|
652
677
|
script/console
|
653
678
|
|
654
|
-
Using the scripts in `./script` instead of `bundle exec rspec`, `bundle
|
655
|
-
console`, etc. ensures your dependencies are up-to-date.
|
679
|
+
Using the scripts in `./script` instead of `bundle exec rspec`, `bundle console`, etc. ensures your dependencies are up-to-date.
|
656
680
|
|
657
681
|
### Code of Conduct
|
658
682
|
|
659
|
-
We want both the Octokit.rb and larger Octokit communities to be
|
683
|
+
We want both the Octokit.rb and larger Octokit communities to be open
|
660
684
|
and welcoming environments. Please read and follow both in spirit and
|
661
685
|
letter [Code of Conduct](CODE_OF_CONDUCT.md).
|
662
686
|
|
@@ -673,43 +697,43 @@ Octokit uses environmental variables for storing credentials used in testing.
|
|
673
697
|
If you are testing an API endpoint that doesn't require authentication, you
|
674
698
|
can get away without any additional configuration. For the most part, tests
|
675
699
|
use an authenticated client, using a token stored in `ENV['OCTOKIT_TEST_GITHUB_TOKEN']`.
|
676
|
-
There are several different
|
700
|
+
There are several different authentication methods used across the api.
|
677
701
|
Here is the full list of configurable environmental variables for testing
|
678
702
|
Octokit:
|
679
703
|
|
680
|
-
ENV Variable
|
681
|
-
|
682
|
-
`OCTOKIT_TEST_GITHUB_LOGIN
|
683
|
-
`OCTOKIT_TEST_GITHUB_PASSWORD
|
684
|
-
`OCTOKIT_TEST_GITHUB_TOKEN`
|
685
|
-
`OCTOKIT_TEST_GITHUB_CLIENT_ID`
|
686
|
-
`OCTOKIT_TEST_GITHUB_CLIENT_SECRET`
|
687
|
-
`OCTOKIT_TEST_GITHUB_REPOSITORY`
|
688
|
-
`OCTOKIT_TEST_GITHUB_ORGANIZATION`
|
689
|
-
`OCTOKIT_TEST_GITHUB_ENTERPRISE_LOGIN`
|
690
|
-
`OCTOKIT_TEST_GITHUB_ENTERPRISE_TOKEN`
|
691
|
-
`OCTOKIT_TEST_GITHUB_ENTERPRISE_MANAGEMENT_CONSOLE_PASSWORD` | GitHub Enterprise management console password.
|
692
|
-
`OCTOKIT_TEST_GITHUB_ENTERPRISE_ENDPOINT`
|
693
|
-
`OCTOKIT_TEST_GITHUB_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT` | GitHub Enterprise Management Console endpoint.
|
694
|
-
`OCTOKIT_TEST_GITHUB_INTEGRATION`
|
695
|
-
`OCTOKIT_TEST_GITHUB_INTEGRATION_INSTALLATION`
|
696
|
-
`OCTOKIT_TEST_INTEGRATION_PEM_KEY`
|
704
|
+
| ENV Variable | Description |
|
705
|
+
| :----------------------------------------------------------- | :------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
706
|
+
| `OCTOKIT_TEST_GITHUB_LOGIN` | GitHub login name (preferably one created specifically for testing against). |
|
707
|
+
| `OCTOKIT_TEST_GITHUB_PASSWORD` | Password for the test GitHub login. |
|
708
|
+
| `OCTOKIT_TEST_GITHUB_TOKEN` | [Personal Access Token](https://github.com/blog/1509-personal-api-tokens) for the test GitHub login. |
|
709
|
+
| `OCTOKIT_TEST_GITHUB_CLIENT_ID` | Test OAuth application client id. |
|
710
|
+
| `OCTOKIT_TEST_GITHUB_CLIENT_SECRET` | Test OAuth application client secret. |
|
711
|
+
| `OCTOKIT_TEST_GITHUB_REPOSITORY` | Test repository to perform destructive actions against, this should not be set to any repository of importance. **Automatically created by the test suite if nonexistent** Default: `api-sandbox` |
|
712
|
+
| `OCTOKIT_TEST_GITHUB_ORGANIZATION` | Test organization. |
|
713
|
+
| `OCTOKIT_TEST_GITHUB_ENTERPRISE_LOGIN` | GitHub Enterprise login name. |
|
714
|
+
| `OCTOKIT_TEST_GITHUB_ENTERPRISE_TOKEN` | GitHub Enterprise token. |
|
715
|
+
| `OCTOKIT_TEST_GITHUB_ENTERPRISE_MANAGEMENT_CONSOLE_PASSWORD` | GitHub Enterprise management console password. |
|
716
|
+
| `OCTOKIT_TEST_GITHUB_ENTERPRISE_ENDPOINT` | GitHub Enterprise hostname. |
|
717
|
+
| `OCTOKIT_TEST_GITHUB_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT` | GitHub Enterprise Management Console endpoint. |
|
718
|
+
| `OCTOKIT_TEST_GITHUB_INTEGRATION` | [GitHub Integration](https://developer.github.com/early-access/integrations/) owned by your test organization. |
|
719
|
+
| `OCTOKIT_TEST_GITHUB_INTEGRATION_INSTALLATION` | Installation of the GitHub Integration specified above. |
|
720
|
+
| `OCTOKIT_TEST_INTEGRATION_PEM_KEY` | File path to the private key generated from your integration. |
|
697
721
|
|
698
722
|
Since we periodically refresh our cassettes, please keep some points in mind
|
699
723
|
when writing new specs.
|
700
724
|
|
701
|
-
|
725
|
+
- **Specs should be idempotent**. The HTTP calls made during a spec should be
|
702
726
|
able to be run over and over. This means deleting a known resource prior to
|
703
727
|
creating it if the name has to be unique.
|
704
|
-
|
728
|
+
- **Specs should be able to be run in random order.** If a spec depends on
|
705
729
|
another resource as a fixture, make sure that's created in the scope of the
|
706
730
|
spec and not depend on a previous spec to create the data needed.
|
707
|
-
|
731
|
+
- **Do not depend on authenticated user info.** Instead of asserting
|
708
732
|
actual values in resources, try to assert the existence of a key or that a
|
709
733
|
response is an Array. We're testing the client, not the API.
|
710
734
|
|
711
735
|
[bootstrapping]: http://wynnnetherland.com/linked/2013012801/bootstrapping-consistency
|
712
|
-
[
|
736
|
+
[vcr]: https://github.com/vcr/vcr
|
713
737
|
|
714
738
|
## Supported Ruby Versions
|
715
739
|
|
@@ -719,6 +743,8 @@ implementations:
|
|
719
743
|
* Ruby 2.5
|
720
744
|
* Ruby 2.6
|
721
745
|
* Ruby 2.7
|
746
|
+
* Ruby 3.0
|
747
|
+
* Ruby 3.1
|
722
748
|
|
723
749
|
If something doesn't work on one of these Ruby versions, it's a bug.
|
724
750
|
|
@@ -755,7 +781,8 @@ The changes made between versions can be seen on the [project releases page][rel
|
|
755
781
|
[releases]: https://github.com/octokit/octokit.rb/releases
|
756
782
|
|
757
783
|
## Making Repeating Requests
|
758
|
-
|
784
|
+
|
785
|
+
In most cases it would be best to use [webhooks](https://developer.github.com/webhooks/), but sometimes webhooks don't provide all of the information needed. In those cases where one might need to poll for progress or retry a request on failure, we designed [Octopoller](https://github.com/octokit/octopoller.rb). Octopoller is a micro gem perfect for making repeating requests.
|
759
786
|
|
760
787
|
```ruby
|
761
788
|
Octopoller.poll(timeout: 15.seconds) do
|
data/Rakefile
CHANGED
@@ -1,11 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'bundler'
|
2
4
|
Bundler::GemHelper.install_tasks
|
3
5
|
|
4
6
|
require 'rspec/core/rake_task'
|
5
7
|
RSpec::Core::RakeTask.new(:spec)
|
6
8
|
|
7
|
-
task :
|
8
|
-
task :
|
9
|
+
task test: :spec
|
10
|
+
task default: :spec
|
9
11
|
|
10
12
|
namespace :doc do
|
11
13
|
begin
|
@@ -14,7 +16,7 @@ namespace :doc do
|
|
14
16
|
task.files = ['README.md', 'LICENSE.md', 'lib/**/*.rb']
|
15
17
|
task.options = [
|
16
18
|
'--output-dir', 'doc/yard',
|
17
|
-
'--markup', 'markdown'
|
19
|
+
'--markup', 'markdown'
|
18
20
|
]
|
19
21
|
end
|
20
22
|
rescue LoadError
|
data/lib/ext/sawyer/relation.rb
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
require 'sawyer'
|
2
4
|
|
3
5
|
patch = Module.new do
|
4
|
-
def href(options=nil)
|
6
|
+
def href(options = nil)
|
5
7
|
# Temporary workaround for: https://github.com/octokit/octokit.rb/issues/727
|
6
|
-
name.to_s ==
|
8
|
+
name.to_s == 'ssh' ? @href : super
|
7
9
|
end
|
8
10
|
end
|
9
11
|
|
data/lib/octokit/arguments.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module Octokit
|
3
4
|
# Extracts options from method arguments
|
4
5
|
# @private
|
5
6
|
class Arguments < Array
|
@@ -9,6 +10,5 @@ module Octokit
|
|
9
10
|
@options = args.last.is_a?(::Hash) ? args.pop : {}
|
10
11
|
super(args)
|
11
12
|
end
|
12
|
-
|
13
13
|
end
|
14
14
|
end
|
@@ -1,7 +1,15 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
2
|
|
3
|
+
module Octokit
|
3
4
|
# Authentication methods for {Octokit::Client}
|
4
5
|
module Authentication
|
6
|
+
# In Faraday 2.x, the authorization middleware uses new interface
|
7
|
+
FARADAY_BASIC_AUTH_KEYS =
|
8
|
+
if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.0')
|
9
|
+
%i[authorization basic]
|
10
|
+
else
|
11
|
+
[:basic_auth]
|
12
|
+
end
|
5
13
|
|
6
14
|
# Indicates if the client was supplied Basic Auth
|
7
15
|
# username and password
|
@@ -66,8 +74,7 @@ module Octokit
|
|
66
74
|
self.password = creds.shift
|
67
75
|
end
|
68
76
|
rescue LoadError
|
69
|
-
octokit_warn
|
77
|
+
octokit_warn 'Please install netrc gem for .netrc support'
|
70
78
|
end
|
71
|
-
|
72
79
|
end
|
73
80
|
end
|
@@ -1,11 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Actions Secrets API
|
5
6
|
#
|
6
7
|
# @see https://developer.github.com/v3/actions/secrets/
|
7
8
|
module ActionsSecrets
|
8
|
-
|
9
9
|
# Get public key for secrets encryption
|
10
10
|
#
|
11
11
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -15,7 +15,6 @@ module Octokit
|
|
15
15
|
get "#{Repository.path repo}/actions/secrets/public-key"
|
16
16
|
end
|
17
17
|
|
18
|
-
|
19
18
|
# List secrets
|
20
19
|
#
|
21
20
|
# @param repo [Integer, String, Hash, Repository] A GitHub repository
|
@@ -1,10 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
5
|
# Methods for the Actions Workflows API
|
4
6
|
#
|
5
7
|
# @see https://developer.github.com/v3/actions/workflows
|
6
8
|
module ActionsWorkflows
|
7
|
-
|
8
9
|
# Get the workflows in a repository
|
9
10
|
#
|
10
11
|
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
data/lib/octokit/client/apps.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
module Octokit
|
2
4
|
class Client
|
3
|
-
|
4
5
|
# Methods for the Apps API
|
5
6
|
module Apps
|
6
|
-
|
7
7
|
# Get the authenticated App
|
8
8
|
#
|
9
9
|
# @param options [Hash] A customizable set of options
|
@@ -12,7 +12,7 @@ module Octokit
|
|
12
12
|
#
|
13
13
|
# @return [Sawyer::Resource] App information
|
14
14
|
def app(options = {})
|
15
|
-
get
|
15
|
+
get 'app', options
|
16
16
|
end
|
17
17
|
|
18
18
|
# Find all installations that belong to an App
|
@@ -23,16 +23,16 @@ module Octokit
|
|
23
23
|
#
|
24
24
|
# @return [Array<Sawyer::Resource>] the total_count and an array of installations
|
25
25
|
def find_app_installations(options = {})
|
26
|
-
paginate
|
26
|
+
paginate 'app/installations', options
|
27
27
|
end
|
28
28
|
alias find_installations find_app_installations
|
29
29
|
|
30
30
|
def find_integration_installations(options = {})
|
31
31
|
octokit_warn(
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
'Deprecated: Octokit::Client::Apps#find_integration_installations '\
|
33
|
+
'method is deprecated. Please update your call to use '\
|
34
|
+
'Octokit::Client::Apps#find_app_installations before the next major '\
|
35
|
+
'Octokit version update.'
|
36
36
|
)
|
37
37
|
find_app_installations(options)
|
38
38
|
end
|
@@ -45,7 +45,7 @@ module Octokit
|
|
45
45
|
#
|
46
46
|
# @return [Sawyer::Resource] the total_count and an array of installations
|
47
47
|
def find_user_installations(options = {})
|
48
|
-
paginate(
|
48
|
+
paginate('user/installations', options) do |data, last_response|
|
49
49
|
data.installations.concat last_response.data.installations
|
50
50
|
end
|
51
51
|
end
|
@@ -76,10 +76,10 @@ module Octokit
|
|
76
76
|
|
77
77
|
def create_integration_installation_access_token(installation, options = {})
|
78
78
|
octokit_warn(
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
79
|
+
'Deprecated: Octokit::Client::Apps#create_integration_installation_access_token '\
|
80
|
+
'method is deprecated. Please update your call to use '\
|
81
|
+
'Octokit::Client::Apps#create_app_installation_access_token before the next major '\
|
82
|
+
'Octokit version update.'
|
83
83
|
)
|
84
84
|
create_app_installation_access_token(installation, options)
|
85
85
|
end
|
@@ -128,7 +128,7 @@ module Octokit
|
|
128
128
|
#
|
129
129
|
# @return [Sawyer::Resource] the total_count and an array of repositories
|
130
130
|
def list_app_installation_repositories(options = {})
|
131
|
-
paginate(
|
131
|
+
paginate('installation/repositories', options) do |data, last_response|
|
132
132
|
data.repositories.concat last_response.data.repositories
|
133
133
|
end
|
134
134
|
end
|
@@ -136,10 +136,10 @@ module Octokit
|
|
136
136
|
|
137
137
|
def list_integration_installation_repositories(options = {})
|
138
138
|
octokit_warn(
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
139
|
+
'Deprecated: Octokit::Client::Apps#list_integration_installation_repositories '\
|
140
|
+
'method is deprecated. Please update your call to use '\
|
141
|
+
'Octokit::Client::Apps#list_app_installation_repositories before the next major '\
|
142
|
+
'Octokit version update.'
|
143
143
|
)
|
144
144
|
list_app_installation_repositories(options)
|
145
145
|
end
|
@@ -160,10 +160,10 @@ module Octokit
|
|
160
160
|
|
161
161
|
def add_repository_to_integration_installation(installation, repo, options = {})
|
162
162
|
octokit_warn(
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
163
|
+
'Deprecated: Octokit::Client::Apps#add_repository_to_integration_installation '\
|
164
|
+
'method is deprecated. Please update your call to use '\
|
165
|
+
'Octokit::Client::Apps#add_repository_to_app_installation before the next major '\
|
166
|
+
'Octokit version update.'
|
167
167
|
)
|
168
168
|
add_repository_to_app_installation(installation, repo, options)
|
169
169
|
end
|
@@ -184,10 +184,10 @@ module Octokit
|
|
184
184
|
|
185
185
|
def remove_repository_from_integration_installation(installation, repo, options = {})
|
186
186
|
octokit_warn(
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
187
|
+
'Deprecated: Octokit::Client::Apps#remove_repository_from_integration_installation '\
|
188
|
+
'method is deprecated. Please update your call to use '\
|
189
|
+
'Octokit::Client::Apps#remove_repository_from_app_installation before the next major '\
|
190
|
+
'Octokit version update.'
|
191
191
|
)
|
192
192
|
remove_repository_from_app_installation(installation, repo, options)
|
193
193
|
end
|