octokit 6.0.1 → 6.1.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ac7553d8be06123cac2720aa58ad0025845326916a3203f90b8713a6dbb3752
4
- data.tar.gz: 3b0e9e958e9d4014cf9f95609ab078af9466613dc808d63f2a0cd3a666c063d2
3
+ metadata.gz: afa7dae6ede3d3871a1ba78d8c0de33d3aa4692869eacdbb30e0867f555c21f2
4
+ data.tar.gz: 213439dcb01e0af935df22e902caa69d9c395b1ab9076a83918efebc374140bd
5
5
  SHA512:
6
- metadata.gz: 5e0ffef0af68dc1270dc8f1af6cb841532b295dce58aa46cf8e6969f02d4ec1ab117a1198e136350bb630fb6d6120b4231a5d635214b693c997e0b990397258a
7
- data.tar.gz: 269e9d3a3fcdb270dfa274d4225a8fa7f2de23280eae137aca3b82a1355f305dcc0fa93c23333a48760004503d9c4336231c588ee8135f1f7ce1434c1a180166
6
+ metadata.gz: 117e024b6078555cdd6809d941a19a0e8b77e629939e112ffe5a5116674c16d6b441358e3ba56bc2d27770fea108fd4adc18d48aa6c186206628abc28dd525d9
7
+ data.tar.gz: 4caea9cb705c43d9c8022f0de6d74cc9ece8d1e1771ae7a43c0e53a748c226a8c231fe25c64b813bf025a80521dd5c201eb7d2693ebbd6074d47a776137dd7fb
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](#quick-start)
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
- 8. [Pagination](#pagination)
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
- 9. [Working with GitHub Enterprise](#working-with-github-enterprise)
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
- 10. [Configuration and defaults](#configuration-and-defaults)
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
- 11. [Hypermedia agent](#hypermedia-agent)
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
- 12. [Upgrading guide](#upgrading-guide)
45
+ 13. [Upgrading guide](#upgrading-guide)
44
46
  1. [Upgrading from 1.x.x](#upgrading-from-1xx)
45
- 13. [Advanced usage](#advanced-usage)
47
+ 14. [Advanced usage](#advanced-usage)
46
48
  1. [Debugging](#debugging)
47
49
  2. [Caching](#caching)
48
- 14. [Hacking on Octokit.rb](#hacking-on-octokitrb)
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
- 15. [Supported Ruby Versions](#supported-ruby-versions)
52
- 16. [Versioning](#versioning)
53
- 17. [Making Repeating Requests](#making-repeating-requests)
54
- 18. [License](#license)
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
- begin
14
- require 'yard'
15
- YARD::Rake::YardocTask.new do |task|
16
- task.files = ['README.md', 'LICENSE.md', 'lib/**/*.rb']
17
- task.options = [
18
- '--output-dir', 'doc/yard',
19
- '--markup', 'markdown'
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
@@ -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
 
@@ -163,10 +163,10 @@ module Octokit
163
163
  inspected.gsub! @bearer_token, '********' if @bearer_token
164
164
  # Only show last 4 of token, secret
165
165
  if @access_token
166
- inspected.gsub! @access_token, "#{'*' * 36}#{@access_token[36..-1]}"
166
+ inspected.gsub! @access_token, "#{'*' * 36}#{@access_token[36..]}"
167
167
  end
168
168
  if @client_secret
169
- inspected.gsub! @client_secret, "#{'*' * 36}#{@client_secret[36..-1]}"
169
+ inspected.gsub! @client_secret, "#{'*' * 36}#{@client_secret[36..]}"
170
170
  end
171
171
 
172
172
  inspected
@@ -144,7 +144,7 @@ module Octokit
144
144
  private
145
145
 
146
146
  def options
147
- Octokit::Configurable.keys.map { |key| [key, instance_variable_get(:"@#{key}")] }.to_h
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 = {})
@@ -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
- builder.use Faraday::Request::Retry, exceptions: [Octokit::ServerError]
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
- builder.use Faraday::Retry::Middleware, exceptions: [Octokit::ServerError]
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.map { |key| [key, send(key)] }.to_h
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/gist.rb CHANGED
@@ -10,7 +10,7 @@ module Octokit
10
10
  # Instantiate {Gist} object from Gist URL
11
11
  # @ return [Gist]
12
12
  def self.from_url(url)
13
- Gist.new(URI.parse(url).path[1..-1])
13
+ Gist.new(URI.parse(url).path[1..])
14
14
  end
15
15
 
16
16
  def initialize(gist)
@@ -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
- info.limit = (response.headers['X-RateLimit-Limit'] || 1).to_i
25
- info.remaining = (response.headers['X-RateLimit-Remaining'] || 1).to_i
26
- info.resets_at = Time.at((response.headers['X-RateLimit-Reset'] || Time.now).to_i)
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
 
@@ -12,7 +12,7 @@ module Octokit
12
12
  #
13
13
  # @return [Repository]
14
14
  def self.from_url(url)
15
- new URI.parse(url).path[1..-1]
15
+ new URI.parse(url).path[1..]
16
16
  .gsub(%r{^repos/}, '')
17
17
  .split('/', 3)[0..1]
18
18
  .join('/')
@@ -7,11 +7,11 @@ module Octokit
7
7
 
8
8
  # Current minor release.
9
9
  # @return [Integer]
10
- MINOR = 0
10
+ MINOR = 1
11
11
 
12
12
  # Current patch level.
13
13
  # @return [Integer]
14
- PATCH = 1
14
+ PATCH = 0
15
15
 
16
16
  # Full release version.
17
17
  # @return [String]
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: 6.0.1
4
+ version: 6.1.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: 2022-11-23 00:00:00.000000000 Z
13
+ date: 2023-03-09 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler