octokit 6.0.0 → 6.1.1
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/README.md +25 -13
- data/Rakefile +8 -10
- data/lib/octokit/client/environments.rb +55 -0
- data/lib/octokit/client/organizations.rb +16 -0
- data/lib/octokit/client/repositories.rb +1 -1
- data/lib/octokit/client/search.rb +1 -0
- data/lib/octokit/client.rb +4 -2
- data/lib/octokit/configurable.rb +1 -1
- data/lib/octokit/connection.rb +9 -1
- data/lib/octokit/default.rb +5 -3
- data/lib/octokit/error.rb +2 -2
- data/lib/octokit/gist.rb +1 -1
- data/lib/octokit/rate_limit.rb +6 -4
- data/lib/octokit/repository.rb +1 -1
- data/lib/octokit/version.rb +2 -2
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 68c11fbd1bb2d452acf5bbebf33974285207aa99513b22b4ff8d208e01f76e11
|
4
|
+
data.tar.gz: 63c099454a0ffcdbc621990114adbec36d44535929dfbfacaf09bb3d1b34394f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7ed6fb3bdf0b189ed74e8d12705fd9c377407910a6f8f5a8bd6a16f47326b86126dbf973fbbd6045c3b7f31202fa8af9120fbf8acf99cab1f26765be8413bfc
|
7
|
+
data.tar.gz: 52da944c212373baa9a68476e719dd5b2156bccbd09f0d6028edcf34ca90e15961499cfc88acda86ac7fa6625576005cf79d1c2c7eb8cd9f6f2c453317bbe054
|
data/README.md
CHANGED
@@ -13,7 +13,7 @@ Upgrading? Check the [Upgrade Guide](#upgrading-guide) before bumping to a new
|
|
13
13
|
## Table of Contents
|
14
14
|
|
15
15
|
1. [Philosophy](#philosophy)
|
16
|
-
2. [Installation](#
|
16
|
+
2. [Installation](#installation)
|
17
17
|
3. [Making requests](#making-requests)
|
18
18
|
1. [Additional Query Parameters](#additional-query-parameters)
|
19
19
|
4. [Consuming resources](#consuming-resources)
|
@@ -25,33 +25,35 @@ Upgrading? Check the [Upgrade Guide](#upgrading-guide) before bumping to a new
|
|
25
25
|
3. [Two-Factor Authentication](#two-factor-authentication)
|
26
26
|
4. [Using a .netrc file](#using-a-netrc-file)
|
27
27
|
5. [Application authentication](#application-authentication)
|
28
|
-
|
28
|
+
6. [GitHub App](#github-app)
|
29
|
+
8. [Default results per_page](#default-results-per_page)
|
30
|
+
9. [Pagination](#pagination)
|
29
31
|
1. [Auto pagination](#auto-pagination)
|
30
|
-
|
32
|
+
10. [Working with GitHub Enterprise](#working-with-github-enterprise)
|
31
33
|
1. [Interacting with the GitHub.com APIs in GitHub Enterprise](#interacting-with-the-githubcom-apis-in-github-enterprise)
|
32
34
|
2. [Interacting with the GitHub Enterprise Admin APIs](#interacting-with-the-github-enterprise-admin-apis)
|
33
35
|
3. [Interacting with the GitHub Enterprise Management Console APIs](#interacting-with-the-github-enterprise-management-console-apis)
|
34
36
|
4. [SSL Connection Errors](#ssl-connection-errors)
|
35
|
-
|
37
|
+
11. [Configuration and defaults](#configuration-and-defaults)
|
36
38
|
1. [Configuring module defaults](#configuring-module-defaults)
|
37
39
|
2. [Using ENV variables](#using-env-variables)
|
38
40
|
3. [Timeouts](#timeouts)
|
39
|
-
|
41
|
+
12. [Hypermedia agent](#hypermedia-agent)
|
40
42
|
1. [Hypermedia in Octokit](#hypermedia-in-octokit)
|
41
43
|
2. [URI templates](#uri-templates)
|
42
44
|
3. [The Full Hypermedia Experience™](#the-full-hypermedia-experience)
|
43
|
-
|
45
|
+
13. [Upgrading guide](#upgrading-guide)
|
44
46
|
1. [Upgrading from 1.x.x](#upgrading-from-1xx)
|
45
|
-
|
47
|
+
14. [Advanced usage](#advanced-usage)
|
46
48
|
1. [Debugging](#debugging)
|
47
49
|
2. [Caching](#caching)
|
48
|
-
|
50
|
+
15. [Hacking on Octokit.rb](#hacking-on-octokitrb)
|
49
51
|
1. [Code of Conduct](#code-of-conduct)
|
50
52
|
2. [Running and writing new tests](#running-and-writing-new-tests)
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
53
|
+
16. [Supported Ruby Versions](#supported-ruby-versions)
|
54
|
+
17. [Versioning](#versioning)
|
55
|
+
18. [Making Repeating Requests](#making-repeating-requests)
|
56
|
+
19. [License](#license)
|
55
57
|
|
56
58
|
## Philosophy
|
57
59
|
|
@@ -298,6 +300,15 @@ user = client.user 'defunkt'
|
|
298
300
|
[access scopes]: http://developer.github.com/v3/oauth/#scopes
|
299
301
|
[app-creds]: http://developer.github.com/v3/#increasing-the-unauthenticated-rate-limit-for-oauth-applications
|
300
302
|
|
303
|
+
### GitHub App
|
304
|
+
Octokit.rb also supports authentication [using a GitHub App](https://docs.github.com/en/developers/apps/managing-github-apps/installing-github-apps), which [requires a generated JWT token](https://docs.github.com/en/developers/apps/building-github-apps/authenticating-with-github-apps#authenticating-as-a-github-app).
|
305
|
+
|
306
|
+
```ruby
|
307
|
+
client = Octokit::Client.new(:bearer_token => "<your jwt token>")
|
308
|
+
client.app
|
309
|
+
# => about GitHub App info
|
310
|
+
```
|
311
|
+
|
301
312
|
## Default results per_page
|
302
313
|
|
303
314
|
Default results from the GitHub API are 30, if you wish to add more you must do so during Octokit configuration.
|
@@ -606,7 +617,7 @@ traffic:
|
|
606
617
|
|
607
618
|
```ruby
|
608
619
|
stack = Faraday::RackBuilder.new do |builder|
|
609
|
-
builder.use Faraday::Retry::Middleware, exceptions: [Octokit::ServerError] # or Faraday::Request::Retry for Faraday < 2.0
|
620
|
+
builder.use Faraday::Retry::Middleware, exceptions: Faraday::Request::Retry::DEFAULT_EXCEPTIONS + [Octokit::ServerError] # or Faraday::Request::Retry for Faraday < 2.0
|
610
621
|
builder.use Octokit::Middleware::FollowRedirects
|
611
622
|
builder.use Octokit::Response::RaiseError
|
612
623
|
builder.use Octokit::Response::FeedParser
|
@@ -746,6 +757,7 @@ implementations:
|
|
746
757
|
* Ruby 2.7
|
747
758
|
* Ruby 3.0
|
748
759
|
* Ruby 3.1
|
760
|
+
* Ruby 3.2
|
749
761
|
|
750
762
|
If something doesn't work on one of these Ruby versions, it's a bug.
|
751
763
|
|
data/Rakefile
CHANGED
@@ -10,15 +10,13 @@ task test: :spec
|
|
10
10
|
task default: :spec
|
11
11
|
|
12
12
|
namespace :doc do
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
]
|
21
|
-
end
|
22
|
-
rescue LoadError
|
13
|
+
require 'yard'
|
14
|
+
YARD::Rake::YardocTask.new do |task|
|
15
|
+
task.files = ['README.md', 'LICENSE.md', 'lib/**/*.rb']
|
16
|
+
task.options = [
|
17
|
+
'--output-dir', 'doc/yard',
|
18
|
+
'--markup', 'markdown'
|
19
|
+
]
|
23
20
|
end
|
21
|
+
rescue LoadError
|
24
22
|
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Octokit
|
4
|
+
class Client
|
5
|
+
# Methods for the Environments API
|
6
|
+
#
|
7
|
+
# @see https://docs.github.com/en/rest/deployments/environments
|
8
|
+
module Environments
|
9
|
+
# Fetch a single environment for a repository
|
10
|
+
#
|
11
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
12
|
+
# @param environment_name [String] The name of the environment
|
13
|
+
# @return <Sawyer::Resource> A single environment
|
14
|
+
# @see https://docs.github.com/en/rest/deployments/environments#get-an-environment
|
15
|
+
def environment(repo, environment_name, options = {})
|
16
|
+
get("#{Repository.path repo}/environments/#{environment_name}", options)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Lists the environments for a repository
|
20
|
+
#
|
21
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
22
|
+
# @option options [Integer] :per_page The number of results per page (max 100). Default: 30
|
23
|
+
# @option options [Integer] :page Page number of the results to fetch. Default: 1
|
24
|
+
# @return [Sawyer::Resource] Total count of environments and list of environments
|
25
|
+
# @see https://docs.github.com/en/rest/deployments/environments#list-environments
|
26
|
+
def environments(repo, options = {})
|
27
|
+
get("#{Repository.path repo}/environments", options)
|
28
|
+
end
|
29
|
+
alias list_environments environments
|
30
|
+
|
31
|
+
# Create or update an environment with protection rules, such as required reviewers
|
32
|
+
#
|
33
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
34
|
+
# @param environment_name [String] The name of the environment
|
35
|
+
# @option options [Integer] :wait_timer The amount of time to delay a job after the job is initially triggered. The time (in minutes) must be an integer between 0 and 43,200 (30 days).
|
36
|
+
# @option options [Array] :reviewers The people or teams that may review jobs that reference the environment. You can list up to six users or teams as reviewers.
|
37
|
+
# @option options [Object] :deployment_branch_policy The type of deployment branch policy for this environment. To allow all branches to deploy, set to null.
|
38
|
+
# @return [Sawyer::Resource] An environment
|
39
|
+
# @see https://docs.github.com/en/rest/deployments/environments#create-or-update-an-environment
|
40
|
+
def create_or_update_environment(repo, environment_name, options = {})
|
41
|
+
put("#{Repository.path repo}/environments/#{environment_name}", options)
|
42
|
+
end
|
43
|
+
|
44
|
+
# Delete an Environment
|
45
|
+
#
|
46
|
+
# @param repo [Integer, String, Repository, Hash] A GitHub repository
|
47
|
+
# @param environment_name [String] The name of the environment
|
48
|
+
# @return [No Content]
|
49
|
+
# @see https://docs.github.com/en/rest/deployments/environments#delete-an-environment
|
50
|
+
def delete_environment(repo, environment_name, options = {})
|
51
|
+
delete("#{Repository.path repo}/environments/#{environment_name}", options)
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
@@ -50,6 +50,22 @@ module Octokit
|
|
50
50
|
end
|
51
51
|
alias update_org update_organization
|
52
52
|
|
53
|
+
# Delete an organization.
|
54
|
+
#
|
55
|
+
# Requires authenticated organization owner.
|
56
|
+
#
|
57
|
+
# @param org [String, Integer] Organization login or ID.
|
58
|
+
# @return [Boolean] True if deletion successful, otherwise false.
|
59
|
+
# @see https://docs.github.com/rest/orgs/orgs#delete-an-organization
|
60
|
+
# @example
|
61
|
+
# @client.delete_organization("my-org")
|
62
|
+
# @example
|
63
|
+
# @client.delete_org("my-org")
|
64
|
+
def delete_organization(org)
|
65
|
+
boolean_from_response :delete, Organization.path(org)
|
66
|
+
end
|
67
|
+
alias delete_org delete_organization
|
68
|
+
|
53
69
|
# Get organizations for a user.
|
54
70
|
#
|
55
71
|
# Nonauthenticated calls to this method will return organizations that
|
@@ -564,7 +564,7 @@ module Octokit
|
|
564
564
|
# @example Get branch 'master` from octokit/octokit.rb
|
565
565
|
# Octokit.branch("octokit/octokit.rb", "master")
|
566
566
|
def branch(repo, branch, options = {})
|
567
|
-
get "#{Repository.path repo}/branches/#{branch}", options
|
567
|
+
get "#{Repository.path repo}/branches/#{CGI.escape(branch)}", options
|
568
568
|
end
|
569
569
|
alias get_branch branch
|
570
570
|
|
@@ -44,6 +44,7 @@ module Octokit
|
|
44
44
|
# @option options [Integer] :per_page Number of items per page
|
45
45
|
# @return [Sawyer::Resource] Search results object
|
46
46
|
# @see https://developer.github.com/v3/search/#search-issues-and-pull-requests
|
47
|
+
# @see https://docs.github.com/en/rest/search#limitations-on-query-length
|
47
48
|
def search_issues(query, options = {})
|
48
49
|
search 'search/issues', query, options
|
49
50
|
end
|
data/lib/octokit/client.rb
CHANGED
@@ -26,6 +26,7 @@ require 'octokit/client/community_profile'
|
|
26
26
|
require 'octokit/client/contents'
|
27
27
|
require 'octokit/client/downloads'
|
28
28
|
require 'octokit/client/deployments'
|
29
|
+
require 'octokit/client/environments'
|
29
30
|
require 'octokit/client/emojis'
|
30
31
|
require 'octokit/client/events'
|
31
32
|
require 'octokit/client/feeds'
|
@@ -86,6 +87,7 @@ module Octokit
|
|
86
87
|
include Octokit::Client::Contents
|
87
88
|
include Octokit::Client::Deployments
|
88
89
|
include Octokit::Client::Downloads
|
90
|
+
include Octokit::Client::Environments
|
89
91
|
include Octokit::Client::Emojis
|
90
92
|
include Octokit::Client::Events
|
91
93
|
include Octokit::Client::Feeds
|
@@ -163,10 +165,10 @@ module Octokit
|
|
163
165
|
inspected.gsub! @bearer_token, '********' if @bearer_token
|
164
166
|
# Only show last 4 of token, secret
|
165
167
|
if @access_token
|
166
|
-
inspected.gsub! @access_token, "#{'*' * 36}#{@access_token[36
|
168
|
+
inspected.gsub! @access_token, "#{'*' * 36}#{@access_token[36..]}"
|
167
169
|
end
|
168
170
|
if @client_secret
|
169
|
-
inspected.gsub! @client_secret, "#{'*' * 36}#{@client_secret[36
|
171
|
+
inspected.gsub! @client_secret, "#{'*' * 36}#{@client_secret[36..]}"
|
170
172
|
end
|
171
173
|
|
172
174
|
inspected
|
data/lib/octokit/configurable.rb
CHANGED
@@ -144,7 +144,7 @@ module Octokit
|
|
144
144
|
private
|
145
145
|
|
146
146
|
def options
|
147
|
-
Octokit::Configurable.keys.
|
147
|
+
Octokit::Configurable.keys.to_h { |key| [key, instance_variable_get(:"@#{key}")] }
|
148
148
|
end
|
149
149
|
|
150
150
|
def fetch_client_id_and_secret(overrides = {})
|
data/lib/octokit/connection.rb
CHANGED
@@ -154,7 +154,7 @@ module Octokit
|
|
154
154
|
end
|
155
155
|
|
156
156
|
@last_response = response = agent.call(method, Addressable::URI.parse(path.to_s).normalize.to_s, data, options)
|
157
|
-
response
|
157
|
+
response_data_correctly_encoded(response)
|
158
158
|
rescue Octokit::Error => e
|
159
159
|
@last_response = nil
|
160
160
|
raise e
|
@@ -206,5 +206,13 @@ module Octokit
|
|
206
206
|
|
207
207
|
opts
|
208
208
|
end
|
209
|
+
|
210
|
+
def response_data_correctly_encoded(response)
|
211
|
+
content_type = response.headers.fetch('content-type', '')
|
212
|
+
return response.data unless content_type.include?('charset') && response.data.is_a?(String)
|
213
|
+
|
214
|
+
reported_encoding = content_type.match(/charset=([^ ]+)/)[1]
|
215
|
+
response.data.force_encoding(reported_encoding)
|
216
|
+
end
|
209
217
|
end
|
210
218
|
end
|
data/lib/octokit/default.rb
CHANGED
@@ -34,9 +34,11 @@ module Octokit
|
|
34
34
|
# In Faraday 2.x, Faraday::Request::Retry was moved to a separate gem
|
35
35
|
# so we use it only when it's available.
|
36
36
|
if defined?(Faraday::Request::Retry)
|
37
|
-
|
37
|
+
retry_exceptions = Faraday::Request::Retry::DEFAULT_EXCEPTIONS + [Octokit::ServerError]
|
38
|
+
builder.use Faraday::Request::Retry, exceptions: retry_exceptions
|
38
39
|
elsif defined?(Faraday::Retry::Middleware)
|
39
|
-
|
40
|
+
retry_exceptions = Faraday::Retry::Middleware::DEFAULT_EXCEPTIONS + [Octokit::ServerError]
|
41
|
+
builder.use Faraday::Retry::Middleware, exceptions: retry_exceptions
|
40
42
|
end
|
41
43
|
|
42
44
|
builder.use Octokit::Middleware::FollowRedirects
|
@@ -49,7 +51,7 @@ module Octokit
|
|
49
51
|
# Configuration options
|
50
52
|
# @return [Hash]
|
51
53
|
def options
|
52
|
-
Octokit::Configurable.keys.
|
54
|
+
Octokit::Configurable.keys.to_h { |key| [key, send(key)] }
|
53
55
|
end
|
54
56
|
|
55
57
|
# Default access token from ENV
|
data/lib/octokit/error.rb
CHANGED
@@ -77,7 +77,7 @@ module Octokit
|
|
77
77
|
Octokit::TooManyRequests
|
78
78
|
when /login attempts exceeded/i
|
79
79
|
Octokit::TooManyLoginAttempts
|
80
|
-
when /(returns|for) blobs (up to|between) [0-9
|
80
|
+
when /(returns|for) blobs (up to|between) [0-9-]+ MB/i
|
81
81
|
Octokit::TooLargeContent
|
82
82
|
when /abuse/i
|
83
83
|
Octokit::AbuseDetected
|
@@ -213,7 +213,7 @@ module Octokit
|
|
213
213
|
end
|
214
214
|
|
215
215
|
def redact_url(url_string)
|
216
|
-
%w[client_secret access_token].each do |token|
|
216
|
+
%w[client_secret access_token api_key].each do |token|
|
217
217
|
if url_string.include? token
|
218
218
|
url_string.gsub!(/#{token}=\S+/, "#{token}=(redacted)")
|
219
219
|
end
|
data/lib/octokit/gist.rb
CHANGED
data/lib/octokit/rate_limit.rb
CHANGED
@@ -20,10 +20,12 @@ module Octokit
|
|
20
20
|
# @return [RateLimit]
|
21
21
|
def self.from_response(response)
|
22
22
|
info = new
|
23
|
-
if response.respond_to?(:headers) && !response.headers.nil?
|
24
|
-
|
25
|
-
|
26
|
-
info.
|
23
|
+
headers = response.headers if response.respond_to?(:headers) && !response.headers.nil?
|
24
|
+
headers ||= response.response_headers if response.respond_to?(:response_headers) && !response.response_headers.nil?
|
25
|
+
if headers
|
26
|
+
info.limit = (headers['X-RateLimit-Limit'] || 1).to_i
|
27
|
+
info.remaining = (headers['X-RateLimit-Remaining'] || 1).to_i
|
28
|
+
info.resets_at = Time.at((headers['X-RateLimit-Reset'] || Time.now).to_i)
|
27
29
|
info.resets_in = [(info.resets_at - Time.now).to_i, 0].max
|
28
30
|
end
|
29
31
|
|
data/lib/octokit/repository.rb
CHANGED
data/lib/octokit/version.rb
CHANGED
metadata
CHANGED
@@ -1,16 +1,16 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: octokit
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wynn Netherland
|
8
8
|
- Erik Michaels-Ober
|
9
9
|
- Clint Shryock
|
10
|
-
autorequire:
|
10
|
+
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date:
|
13
|
+
date: 2023-04-06 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: bundler
|
@@ -101,6 +101,7 @@ files:
|
|
101
101
|
- lib/octokit/client/deployments.rb
|
102
102
|
- lib/octokit/client/downloads.rb
|
103
103
|
- lib/octokit/client/emojis.rb
|
104
|
+
- lib/octokit/client/environments.rb
|
104
105
|
- lib/octokit/client/events.rb
|
105
106
|
- lib/octokit/client/feeds.rb
|
106
107
|
- lib/octokit/client/gists.rb
|
@@ -168,7 +169,7 @@ licenses:
|
|
168
169
|
- MIT
|
169
170
|
metadata:
|
170
171
|
rubygems_mfa_required: 'true'
|
171
|
-
post_install_message:
|
172
|
+
post_install_message:
|
172
173
|
rdoc_options: []
|
173
174
|
require_paths:
|
174
175
|
- lib
|
@@ -183,8 +184,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
184
|
- !ruby/object:Gem::Version
|
184
185
|
version: 1.3.5
|
185
186
|
requirements: []
|
186
|
-
rubygems_version: 3.1.
|
187
|
-
signing_key:
|
187
|
+
rubygems_version: 3.1.2
|
188
|
+
signing_key:
|
188
189
|
specification_version: 4
|
189
190
|
summary: Ruby toolkit for working with the GitHub API
|
190
191
|
test_files: []
|