octokit 6.0.1 → 6.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3ac7553d8be06123cac2720aa58ad0025845326916a3203f90b8713a6dbb3752
4
- data.tar.gz: 3b0e9e958e9d4014cf9f95609ab078af9466613dc808d63f2a0cd3a666c063d2
3
+ metadata.gz: 68c11fbd1bb2d452acf5bbebf33974285207aa99513b22b4ff8d208e01f76e11
4
+ data.tar.gz: 63c099454a0ffcdbc621990114adbec36d44535929dfbfacaf09bb3d1b34394f
5
5
  SHA512:
6
- metadata.gz: 5e0ffef0af68dc1270dc8f1af6cb841532b295dce58aa46cf8e6969f02d4ec1ab117a1198e136350bb630fb6d6120b4231a5d635214b693c997e0b990397258a
7
- data.tar.gz: 269e9d3a3fcdb270dfa274d4225a8fa7f2de23280eae137aca3b82a1355f305dcc0fa93c23333a48760004503d9c4336231c588ee8135f1f7ce1434c1a180166
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](#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
@@ -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
@@ -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..-1]}"
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..-1]}"
171
+ inspected.gsub! @client_secret, "#{'*' * 36}#{@client_secret[36..]}"
170
172
  end
171
173
 
172
174
  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/error.rb CHANGED
@@ -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
@@ -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,7 +7,7 @@ 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]
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.1
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-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