octokit 4.14.0 → 4.19.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.
- checksums.yaml +4 -4
- data/CONTRIBUTING.md +14 -13
- data/README.md +15 -12
- data/lib/octokit/authentication.rb +2 -11
- data/lib/octokit/client/actions_secrets.rb +58 -0
- data/lib/octokit/client/actions_workflow_runs.rb +94 -0
- data/lib/octokit/client/actions_workflows.rb +43 -0
- data/lib/octokit/client/apps.rb +34 -8
- data/lib/octokit/client/authorizations.rb +2 -70
- data/lib/octokit/client/commit_branches.rb +20 -0
- data/lib/octokit/client/commit_pulls.rb +20 -0
- data/lib/octokit/client/events.rb +1 -0
- data/lib/octokit/client/issues.rb +7 -2
- data/lib/octokit/client/oauth_applications.rb +122 -0
- data/lib/octokit/client/organizations.rb +24 -10
- data/lib/octokit/client/pull_requests.rb +1 -1
- data/lib/octokit/client/refs.rb +7 -3
- data/lib/octokit/client/repositories.rb +45 -8
- data/lib/octokit/client/repository_invitations.rb +1 -1
- data/lib/octokit/client/reviews.rb +18 -0
- data/lib/octokit/client/search.rb +1 -1
- data/lib/octokit/client/users.rb +86 -0
- data/lib/octokit/client.rb +12 -0
- data/lib/octokit/connection.rb +11 -8
- data/lib/octokit/error.rb +33 -1
- data/lib/octokit/middleware/follow_redirects.rb +1 -1
- data/lib/octokit/preview.rb +8 -1
- data/lib/octokit/rate_limit.rb +1 -1
- data/lib/octokit/version.rb +1 -1
- data/octokit.gemspec +1 -0
- metadata +22 -2
data/lib/octokit/connection.rb
CHANGED
@@ -113,7 +113,7 @@ module Octokit
|
|
113
113
|
elsif bearer_authenticated?
|
114
114
|
http.authorization 'Bearer', @bearer_token
|
115
115
|
elsif application_authenticated?
|
116
|
-
http.
|
116
|
+
http.basic_auth(@client_id, @client_secret)
|
117
117
|
end
|
118
118
|
end
|
119
119
|
end
|
@@ -155,6 +155,9 @@ module Octokit
|
|
155
155
|
|
156
156
|
@last_response = response = agent.call(method, Addressable::URI.parse(path.to_s).normalize.to_s, data, options)
|
157
157
|
response.data
|
158
|
+
rescue Octokit::Error => error
|
159
|
+
@last_response = nil
|
160
|
+
raise error
|
158
161
|
end
|
159
162
|
|
160
163
|
# Executes the request, checking if it was successful
|
@@ -162,7 +165,7 @@ module Octokit
|
|
162
165
|
# @return [Boolean] True on success, false otherwise
|
163
166
|
def boolean_from_response(method, path, options = {})
|
164
167
|
request(method, path, options)
|
165
|
-
@last_response.status
|
168
|
+
[201, 202, 204].include? @last_response.status
|
166
169
|
rescue Octokit::NotFound
|
167
170
|
false
|
168
171
|
end
|
@@ -177,12 +180,12 @@ module Octokit
|
|
177
180
|
conn_opts[:proxy] = @proxy if @proxy
|
178
181
|
if conn_opts[:ssl].nil?
|
179
182
|
conn_opts[:ssl] = { :verify_mode => @ssl_verify_mode } if @ssl_verify_mode
|
180
|
-
else
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
183
|
+
else
|
184
|
+
verify = @connection_options[:ssl][:verify]
|
185
|
+
conn_opts[:ssl] = {
|
186
|
+
:verify => verify,
|
187
|
+
:verify_mode => verify == false ? 0 : @ssl_verify_mode
|
188
|
+
}
|
186
189
|
end
|
187
190
|
opts[:faraday] = Faraday.new(conn_opts)
|
188
191
|
|
data/lib/octokit/error.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module Octokit
|
2
2
|
# Custom error class for rescuing from all GitHub errors
|
3
3
|
class Error < StandardError
|
4
|
-
|
4
|
+
attr_reader :context
|
5
5
|
# Returns the appropriate Octokit::Error subclass based
|
6
6
|
# on status and response message
|
7
7
|
#
|
@@ -34,9 +34,16 @@ module Octokit
|
|
34
34
|
end
|
35
35
|
end
|
36
36
|
|
37
|
+
def build_error_context
|
38
|
+
if RATE_LIMITED_ERRORS.include?(self.class)
|
39
|
+
@context = Octokit::RateLimit.from_response(@response)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
37
43
|
def initialize(response=nil)
|
38
44
|
@response = response
|
39
45
|
super(build_error_message)
|
46
|
+
build_error_context
|
40
47
|
end
|
41
48
|
|
42
49
|
# Documentation URL returned by the API for some errors
|
@@ -63,6 +70,8 @@ module Octokit
|
|
63
70
|
Octokit::TooManyRequests
|
64
71
|
elsif body =~ /login attempts exceeded/i
|
65
72
|
Octokit::TooManyLoginAttempts
|
73
|
+
elsif body =~ /returns blobs up to [0-9]+ MB/i
|
74
|
+
Octokit::TooLargeContent
|
66
75
|
elsif body =~ /abuse/i
|
67
76
|
Octokit::AbuseDetected
|
68
77
|
elsif body =~ /repository access blocked/i
|
@@ -71,6 +80,12 @@ module Octokit
|
|
71
80
|
Octokit::UnverifiedEmail
|
72
81
|
elsif body =~ /account was suspended/i
|
73
82
|
Octokit::AccountSuspended
|
83
|
+
elsif body =~ /billing issue/i
|
84
|
+
Octokit::BillingIssue
|
85
|
+
elsif body =~ /Resource protected by organization SAML enforcement/i
|
86
|
+
Octokit::SAMLProtected
|
87
|
+
elsif body =~ /suspended your access/i
|
88
|
+
Octokit::InstallationSuspended
|
74
89
|
else
|
75
90
|
Octokit::Forbidden
|
76
91
|
end
|
@@ -231,6 +246,10 @@ module Octokit
|
|
231
246
|
# and body matches 'login attempts exceeded'
|
232
247
|
class TooManyLoginAttempts < Forbidden; end
|
233
248
|
|
249
|
+
# Raised when GitHub returns a 403 HTTP status code
|
250
|
+
# and body matches 'returns blobs up to [0-9]+ MB'
|
251
|
+
class TooLargeContent < Forbidden; end
|
252
|
+
|
234
253
|
# Raised when GitHub returns a 403 HTTP status code
|
235
254
|
# and body matches 'abuse'
|
236
255
|
class AbuseDetected < Forbidden; end
|
@@ -247,6 +266,18 @@ module Octokit
|
|
247
266
|
# and body matches 'account was suspended'
|
248
267
|
class AccountSuspended < Forbidden; end
|
249
268
|
|
269
|
+
# Raised when GitHub returns a 403 HTTP status code
|
270
|
+
# and body matches 'billing issue'
|
271
|
+
class BillingIssue < Forbidden; end
|
272
|
+
|
273
|
+
# Raised when GitHub returns a 403 HTTP status code
|
274
|
+
# and body matches 'Resource protected by organization SAML enforcement'
|
275
|
+
class SAMLProtected < Forbidden; end
|
276
|
+
|
277
|
+
# Raised when GitHub returns a 403 HTTP status code
|
278
|
+
# and body matches 'suspended your access'
|
279
|
+
class InstallationSuspended < Forbidden; end
|
280
|
+
|
250
281
|
# Raised when GitHub returns a 404 HTTP status code
|
251
282
|
class NotFound < ClientError; end
|
252
283
|
|
@@ -297,4 +328,5 @@ module Octokit
|
|
297
328
|
# Raised when a repository is created with an invalid format
|
298
329
|
class InvalidRepository < ArgumentError; end
|
299
330
|
|
331
|
+
RATE_LIMITED_ERRORS = [Octokit::TooManyRequests, Octokit::AbuseDetected]
|
300
332
|
end
|
@@ -11,7 +11,7 @@ module Octokit
|
|
11
11
|
module Middleware
|
12
12
|
|
13
13
|
# Public: Exception thrown when the maximum amount of requests is exceeded.
|
14
|
-
class RedirectLimitReached < Faraday::
|
14
|
+
class RedirectLimitReached < Faraday::ClientError
|
15
15
|
attr_reader :response
|
16
16
|
|
17
17
|
def initialize(response)
|
data/lib/octokit/preview.rb
CHANGED
@@ -4,9 +4,12 @@ module Octokit
|
|
4
4
|
module Preview
|
5
5
|
|
6
6
|
PREVIEW_TYPES = {
|
7
|
-
:
|
7
|
+
:applications_api => 'application/vnd.github.doctor-strange-preview+json'.freeze,
|
8
|
+
:branch_protection => 'application/vnd.github.luke-cage-preview+json'.freeze,
|
8
9
|
:checks => 'application/vnd.github.antiope-preview+json'.freeze,
|
9
10
|
:commit_search => 'application/vnd.github.cloak-preview+json'.freeze,
|
11
|
+
:commit_pulls => 'application/vnd.github.groot-preview+json'.freeze,
|
12
|
+
:commit_branches => 'application/vnd.github.groot-preview+json'.freeze,
|
10
13
|
:migrations => 'application/vnd.github.wyandotte-preview+json'.freeze,
|
11
14
|
:licenses => 'application/vnd.github.drax-preview+json'.freeze,
|
12
15
|
:source_imports => 'application/vnd.github.barred-rock-preview'.freeze,
|
@@ -21,6 +24,10 @@ module Octokit
|
|
21
24
|
:topics => 'application/vnd.github.mercy-preview+json'.freeze,
|
22
25
|
:community_profile => 'application/vnd.github.black-panther-preview+json'.freeze,
|
23
26
|
:strict_validation => 'application/vnd.github.speedy-preview+json'.freeze,
|
27
|
+
:drafts => 'application/vnd.github.shadow-cat-preview'.freeze,
|
28
|
+
:template_repositories => 'application/vnd.github.baptiste-preview+json'.freeze,
|
29
|
+
:uninstall_github_app => 'application/vnd.github.gambit-preview+json'.freeze,
|
30
|
+
:project_card_events => 'application/vnd.github.starfox-preview+json'.freeze,
|
24
31
|
}
|
25
32
|
|
26
33
|
def ensure_api_media_type(type, options)
|
data/lib/octokit/rate_limit.rb
CHANGED
@@ -20,7 +20,7 @@ module Octokit
|
|
20
20
|
# @return [RateLimit]
|
21
21
|
def self.from_response(response)
|
22
22
|
info = new
|
23
|
-
if response && !response.headers.nil?
|
23
|
+
if response && response.respond_to?(:headers) && !response.headers.nil?
|
24
24
|
info.limit = (response.headers['X-RateLimit-Limit'] || 1).to_i
|
25
25
|
info.remaining = (response.headers['X-RateLimit-Remaining'] || 1).to_i
|
26
26
|
info.resets_at = Time.at((response.headers['X-RateLimit-Reset'] || Time.now).to_i)
|
data/lib/octokit/version.rb
CHANGED
data/octokit.gemspec
CHANGED
@@ -6,6 +6,7 @@ require 'octokit/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.add_development_dependency 'bundler', '>= 1', '< 3'
|
8
8
|
spec.add_dependency 'sawyer', '>= 0.5.3', '~> 0.8.0'
|
9
|
+
spec.add_dependency 'faraday', '>= 0.9'
|
9
10
|
spec.authors = ["Wynn Netherland", "Erik Michaels-Ober", "Clint Shryock"]
|
10
11
|
spec.description = %q{Simple wrapper for the GitHub API}
|
11
12
|
spec.email = ['wynn.netherland@gmail.com', 'sferik@gmail.com', 'clint@ctshryock.com']
|
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.19.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:
|
13
|
+
date: 2020-10-20 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -52,6 +52,20 @@ dependencies:
|
|
52
52
|
- - "~>"
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: 0.8.0
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: faraday
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0.9'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0.9'
|
55
69
|
description: Simple wrapper for the GitHub API
|
56
70
|
email:
|
57
71
|
- wynn.netherland@gmail.com
|
@@ -71,10 +85,15 @@ files:
|
|
71
85
|
- lib/octokit/arguments.rb
|
72
86
|
- lib/octokit/authentication.rb
|
73
87
|
- lib/octokit/client.rb
|
88
|
+
- lib/octokit/client/actions_secrets.rb
|
89
|
+
- lib/octokit/client/actions_workflow_runs.rb
|
90
|
+
- lib/octokit/client/actions_workflows.rb
|
74
91
|
- lib/octokit/client/apps.rb
|
75
92
|
- lib/octokit/client/authorizations.rb
|
76
93
|
- lib/octokit/client/checks.rb
|
94
|
+
- lib/octokit/client/commit_branches.rb
|
77
95
|
- lib/octokit/client/commit_comments.rb
|
96
|
+
- lib/octokit/client/commit_pulls.rb
|
78
97
|
- lib/octokit/client/commits.rb
|
79
98
|
- lib/octokit/client/community_profile.rb
|
80
99
|
- lib/octokit/client/contents.rb
|
@@ -95,6 +114,7 @@ files:
|
|
95
114
|
- lib/octokit/client/meta.rb
|
96
115
|
- lib/octokit/client/milestones.rb
|
97
116
|
- lib/octokit/client/notifications.rb
|
117
|
+
- lib/octokit/client/oauth_applications.rb
|
98
118
|
- lib/octokit/client/objects.rb
|
99
119
|
- lib/octokit/client/organizations.rb
|
100
120
|
- lib/octokit/client/pages.rb
|