octokit 5.0.0 → 5.1.0

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: dea88415ddb72dde720faee8a6616de5626c6cca81ec294515b96629c2bc8577
4
- data.tar.gz: 29fdb600f3f18770d7966c03bfa87d2331f06652247698b965d2c9237f38ab16
3
+ metadata.gz: abc3f58113bc1ba895a10399af08ffa4cb77046d7ec70b58772fd562a7136f7c
4
+ data.tar.gz: ccb63539ce291e0146c604643445ca0a4013d6329f6345f3dee4a92d01206970
5
5
  SHA512:
6
- metadata.gz: 334851882f7dc5fd9a3da94926cd64e5ef18ad033e5f1038a71589b77d7c27ddf2c2e28ba3ff7b701750eeb69548080bfc4318056f0a88c690c763947a7453bb
7
- data.tar.gz: 23724a2b503a15def78f79c03e21659658274a33c6f2f20cb6cc5fa35064dab3e30bb6862cc4164fe040eb3ac890ee63b79171ad2ed79fdad5de8ef323c62811
6
+ metadata.gz: ca2ff431a0b98c1e38ec32c6fe46c405d5f741a97b33b3288bf44c1cb6641da1ddbd91988114f2174a0740c75c5ab4a63b2b61111a77dfe06ce77ea2b02280dd
7
+ data.tar.gz: 83638f66161513b9f437906515e3f83bc205b1003d9c7fa11d96579d3bab05b19adfd2969c4b59f44d568b9924c75f16fd5aee91b907d6dc3d655e816a9317b4
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Octokit
4
+ class Client
5
+ # Methods for the Actions Workflows jobs API
6
+ #
7
+ # @see https://docs.github.com/rest/actions/workflow-jobs
8
+ module ActionsWorkflowJobs
9
+ # Get a job for a workflow run
10
+ #
11
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
12
+ # @param job_id [Integer, String] Id of the job
13
+ #
14
+ # @return [Sawyer::Resource] Job information
15
+ # @see https://docs.github.com/rest/actions/workflow-jobs#get-a-job-for-a-workflow-run
16
+ def workflow_run_job(repo, job_id, options = {})
17
+ get "#{Repository.path repo}/actions/jobs/#{job_id}", options
18
+ end
19
+
20
+ # Download job logs for a workflow run
21
+ #
22
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
23
+ # @param job_id [Integer, String] Id of the job
24
+ #
25
+ # @return [String] URL to the archived log files of the job
26
+ # @see https://docs.github.com/rest/actions/workflow-jobs#download-job-logs-for-a-workflow-run
27
+ def workflow_run_job_logs(repo, job_id, options = {})
28
+ url = "#{Repository.path repo}/actions/jobs/#{job_id}/logs"
29
+
30
+ response = client_without_redirects.head(url, options)
31
+ response.headers['Location']
32
+ end
33
+
34
+ # List jobs for a workflow run attempt
35
+ #
36
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
37
+ # @param run_id [Integer, String] Id of the workflow run
38
+ # @param attempt_number [Integer, String] Attempt number of the workflow run
39
+ #
40
+ # @return [Sawyer::Resource] Jobs information
41
+ # @see https://docs.github.com/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run-attempt
42
+ def workflow_run_attempt_jobs(repo, run_id, attempt_number, options = {})
43
+ paginate "#{Repository.path repo}/actions/runs/#{run_id}/attempts/#{attempt_number}/jobs", options
44
+ end
45
+ alias list_workflow_run_attempt_jobs workflow_run_attempt_jobs
46
+
47
+ # List jobs for a workflow run
48
+ #
49
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
50
+ # @param run_id [Integer, String] Id of the workflow run
51
+ # @option options [String] :filter Optional filtering by a `completed_at` timestamp
52
+ #
53
+ # @return [Sawyer::Resource] Jobs information
54
+ # @see https://docs.github.com/rest/actions/workflow-jobs#list-jobs-for-a-workflow-run
55
+ def workflow_run_jobs(repo, run_id, options = {})
56
+ paginate "#{Repository.path repo}/actions/runs/#{run_id}/jobs", options
57
+ end
58
+ alias list_workflow_run_jobs workflow_run_jobs
59
+ end
60
+ end
61
+ end
@@ -2,6 +2,9 @@
2
2
 
3
3
  module Octokit
4
4
  class Client
5
+ # Methods for the Actions Workflows runs API
6
+ #
7
+ # @see https://docs.github.com/rest/actions/workflow-runs
5
8
  module ActionsWorkflowRuns
6
9
  # List all runs for a repository workflow
7
10
  #
@@ -92,7 +95,7 @@ module Octokit
92
95
  response.headers['Location']
93
96
  end
94
97
 
95
- # Delets all log files of a workflow run
98
+ # Delete all log files of a workflow run
96
99
  #
97
100
  # @param repo [Integer, String, Repository, Hash] A GitHub repository
98
101
  # @param id [Integer] Id of a workflow run
@@ -102,6 +105,17 @@ module Octokit
102
105
  def delete_workflow_run_logs(repo, id, options = {})
103
106
  boolean_from_response :delete, "#{Repository.path repo}/actions/runs/#{id}/logs", options
104
107
  end
108
+
109
+ # Get workflow run usage
110
+ #
111
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
112
+ # @param id [Integer] Id of a workflow run
113
+ #
114
+ # @return [Sawyer::Resource] Run usage
115
+ # @see https://developer.github.com/v3/actions/workflow-runs/#get-workflow-run-usage
116
+ def workflow_run_usage(repo, id, options = {})
117
+ get "#{Repository.path repo}/actions/runs/#{id}/timing", options
118
+ end
105
119
  end
106
120
  end
107
121
  end
@@ -39,6 +39,28 @@ module Octokit
39
39
  def workflow_dispatch(repo, id, ref, options = {})
40
40
  boolean_from_response :post, "#{Repository.path repo}/actions/workflows/#{id}/dispatches", options.merge({ ref: ref })
41
41
  end
42
+
43
+ # Enable a workflow
44
+ #
45
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
46
+ # @param id [Integer, String] Id or file name of the workflow
47
+ #
48
+ # @return [Boolean] True if workflow was enabled, false otherwise
49
+ # @see https://docs.github.com/en/rest/actions/workflows#enable-a-workflow
50
+ def workflow_enable(repo, id, options = {})
51
+ boolean_from_response :put, "#{Repository.path repo}/actions/workflows/#{id}/enable", options
52
+ end
53
+
54
+ # Disable a workflow
55
+ #
56
+ # @param repo [Integer, String, Repository, Hash] A GitHub repository
57
+ # @param id [Integer, String] Id or file name of the workflow
58
+ #
59
+ # @return [Boolean] True if workflow was disabled, false otherwise
60
+ # @see https://docs.github.com/en/rest/actions/workflows#disable-a-workflow
61
+ def workflow_disable(repo, id, options = {})
62
+ boolean_from_response :put, "#{Repository.path repo}/actions/workflows/#{id}/disable", options
63
+ end
42
64
  end
43
65
  end
44
66
  end
@@ -29,9 +29,9 @@ module Octokit
29
29
 
30
30
  def find_integration_installations(options = {})
31
31
  octokit_warn(
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 '\
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
35
  'Octokit version update.'
36
36
  )
37
37
  find_app_installations(options)
@@ -76,9 +76,9 @@ module Octokit
76
76
 
77
77
  def create_integration_installation_access_token(installation, options = {})
78
78
  octokit_warn(
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 '\
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
82
  'Octokit version update.'
83
83
  )
84
84
  create_app_installation_access_token(installation, options)
@@ -136,9 +136,9 @@ module Octokit
136
136
 
137
137
  def list_integration_installation_repositories(options = {})
138
138
  octokit_warn(
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 '\
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
142
  'Octokit version update.'
143
143
  )
144
144
  list_app_installation_repositories(options)
@@ -160,9 +160,9 @@ module Octokit
160
160
 
161
161
  def add_repository_to_integration_installation(installation, repo, options = {})
162
162
  octokit_warn(
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 '\
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
166
  'Octokit version update.'
167
167
  )
168
168
  add_repository_to_app_installation(installation, repo, options)
@@ -184,9 +184,9 @@ module Octokit
184
184
 
185
185
  def remove_repository_from_integration_installation(installation, repo, options = {})
186
186
  octokit_warn(
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 '\
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
190
  'Octokit version update.'
191
191
  )
192
192
  remove_repository_from_app_installation(installation, repo, options)
@@ -18,11 +18,11 @@ module Octokit
18
18
  # client.subscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
19
19
  def subscribe(topic, callback, secret = nil)
20
20
  options = {
21
- "hub.callback": callback,
22
- "hub.mode": 'subscribe',
23
- "hub.topic": topic
21
+ 'hub.callback': callback,
22
+ 'hub.mode': 'subscribe',
23
+ 'hub.topic': topic
24
24
  }
25
- options.merge!("hub.secret": secret) unless secret.nil?
25
+ options.merge!('hub.secret': secret) unless secret.nil?
26
26
 
27
27
  response = pub_sub_hubbub_request(options)
28
28
 
@@ -40,9 +40,9 @@ module Octokit
40
40
  # client.unsubscribe("https://github.com/joshk/devise_imapable/events/push", "github://Email?address=josh.kalderimis@gmail.com")
41
41
  def unsubscribe(topic, callback)
42
42
  options = {
43
- "hub.callback": callback,
44
- "hub.mode": 'unsubscribe',
45
- "hub.topic": topic
43
+ 'hub.callback': callback,
44
+ 'hub.mode': 'unsubscribe',
45
+ 'hub.topic': topic
46
46
  }
47
47
  response = pub_sub_hubbub_request(options)
48
48
 
@@ -13,9 +13,7 @@ module Octokit
13
13
  # @return [Boolean]
14
14
  def repository?(repo, options = {})
15
15
  !!repository(repo, options)
16
- rescue Octokit::InvalidRepository
17
- false
18
- rescue Octokit::NotFound
16
+ rescue Octokit::InvalidRepository, Octokit::NotFound
19
17
  false
20
18
  end
21
19
 
@@ -161,7 +161,7 @@ module Octokit
161
161
  # TODO(5.0): remove deprecated behavior
162
162
  if reviewers.is_a?(Array)
163
163
  octokit_warn(
164
- 'Deprecated: Octokit::Client#request_pull_request_review '\
164
+ 'Deprecated: Octokit::Client#request_pull_request_review ' \
165
165
  "no longer takes a separate :reviewers argument.\n" \
166
166
  'Please update your call to pass :reviewers and :team_reviewers as part of the options hash.'
167
167
  )
@@ -194,7 +194,7 @@ module Octokit
194
194
  # TODO(5.0): remove deprecated behavior
195
195
  if !reviewers.empty? && !options.empty?
196
196
  octokit_warn(
197
- 'Deprecated: Octokit::Client#delete_pull_request_review_request '\
197
+ 'Deprecated: Octokit::Client#delete_pull_request_review_request ' \
198
198
  "no longer takes a separate :reviewers argument.\n" \
199
199
  'Please update your call to pass :reviewers and :team_reviewers as part of the options hash.'
200
200
  )
@@ -64,6 +64,20 @@ module Octokit
64
64
  end
65
65
  alias search_repos search_repositories
66
66
 
67
+ # Search topics
68
+ #
69
+ # @param query [String] Search term and qualifiers
70
+ # @param options [Hash] Sort and pagination options
71
+ # @option options [String] :sort Sort field
72
+ # @option options [String] :order Sort order (asc or desc)
73
+ # @option options [Integer] :page Page of paginated results
74
+ # @option options [Integer] :per_page Number of items per page
75
+ # @return [Sawyer::Resource] Search results object
76
+ # @see https://developer.github.com/v3/search/#search-topics
77
+ def search_topics(query, options = {})
78
+ search 'search/topics', query, options
79
+ end
80
+
67
81
  # Search users
68
82
  #
69
83
  # @param query [String] Search term and qualifiers
@@ -14,6 +14,7 @@ require 'octokit/organization'
14
14
  require 'octokit/preview'
15
15
  require 'octokit/client/actions_secrets'
16
16
  require 'octokit/client/actions_workflows'
17
+ require 'octokit/client/actions_workflow_jobs'
17
18
  require 'octokit/client/actions_workflow_runs'
18
19
  require 'octokit/client/apps'
19
20
  require 'octokit/client/authorizations'
@@ -93,6 +94,7 @@ module Octokit
93
94
  include Octokit::Client::Gitignore
94
95
  include Octokit::Client::Hooks
95
96
  include Octokit::Client::ActionsWorkflows
97
+ include Octokit::Client::ActionsWorkflowJobs
96
98
  include Octokit::Client::ActionsWorkflowRuns
97
99
  include Octokit::Client::Apps
98
100
  include Octokit::Client::Issues
@@ -134,9 +134,7 @@ module Octokit
134
134
  end
135
135
 
136
136
  def login
137
- @login ||= begin
138
- user.login if token_authenticated?
139
- end
137
+ @login ||= (user.login if token_authenticated?)
140
138
  end
141
139
 
142
140
  def netrc?
@@ -146,7 +144,7 @@ module Octokit
146
144
  private
147
145
 
148
146
  def options
149
- Hash[Octokit::Configurable.keys.map { |key| [key, instance_variable_get(:"@#{key}")] }]
147
+ Octokit::Configurable.keys.map { |key| [key, instance_variable_get(:"@#{key}")] }.to_h
150
148
  end
151
149
 
152
150
  def fetch_client_id_and_secret(overrides = {})
@@ -201,7 +201,7 @@ module Octokit
201
201
  end
202
202
  query = options.delete(:query)
203
203
  opts = { query: options }
204
- opts[:query].merge!(query) if query&.is_a?(Hash)
204
+ opts[:query].merge!(query) if query.is_a?(Hash)
205
205
  opts[:headers] = headers unless headers.empty?
206
206
 
207
207
  opts
@@ -49,55 +49,55 @@ module Octokit
49
49
  # Configuration options
50
50
  # @return [Hash]
51
51
  def options
52
- Hash[Octokit::Configurable.keys.map { |key| [key, send(key)] }]
52
+ Octokit::Configurable.keys.map { |key| [key, send(key)] }.to_h
53
53
  end
54
54
 
55
55
  # Default access token from ENV
56
56
  # @return [String]
57
57
  def access_token
58
- ENV['OCTOKIT_ACCESS_TOKEN']
58
+ ENV.fetch('OCTOKIT_ACCESS_TOKEN', nil)
59
59
  end
60
60
 
61
61
  # Default API endpoint from ENV or {API_ENDPOINT}
62
62
  # @return [String]
63
63
  def api_endpoint
64
- ENV['OCTOKIT_API_ENDPOINT'] || API_ENDPOINT
64
+ ENV.fetch('OCTOKIT_API_ENDPOINT') { API_ENDPOINT }
65
65
  end
66
66
 
67
67
  # Default pagination preference from ENV
68
68
  # @return [String]
69
69
  def auto_paginate
70
- ENV['OCTOKIT_AUTO_PAGINATE']
70
+ ENV.fetch('OCTOKIT_AUTO_PAGINATE', nil)
71
71
  end
72
72
 
73
73
  # Default bearer token from ENV
74
74
  # @return [String]
75
75
  def bearer_token
76
- ENV['OCTOKIT_BEARER_TOKEN']
76
+ ENV.fetch('OCTOKIT_BEARER_TOKEN', nil)
77
77
  end
78
78
 
79
79
  # Default OAuth app key from ENV
80
80
  # @return [String]
81
81
  def client_id
82
- ENV['OCTOKIT_CLIENT_ID']
82
+ ENV.fetch('OCTOKIT_CLIENT_ID', nil)
83
83
  end
84
84
 
85
85
  # Default OAuth app secret from ENV
86
86
  # @return [String]
87
87
  def client_secret
88
- ENV['OCTOKIT_SECRET']
88
+ ENV.fetch('OCTOKIT_SECRET', nil)
89
89
  end
90
90
 
91
91
  # Default management console password from ENV
92
92
  # @return [String]
93
93
  def management_console_password
94
- ENV['OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_PASSWORD']
94
+ ENV.fetch('OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_PASSWORD', nil)
95
95
  end
96
96
 
97
97
  # Default management console endpoint from ENV
98
98
  # @return [String]
99
99
  def management_console_endpoint
100
- ENV['OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT']
100
+ ENV.fetch('OCTOKIT_ENTERPRISE_MANAGEMENT_CONSOLE_ENDPOINT', nil)
101
101
  end
102
102
 
103
103
  # Default options for Faraday::Connection
@@ -114,13 +114,13 @@ module Octokit
114
114
  # Default media type from ENV or {MEDIA_TYPE}
115
115
  # @return [String]
116
116
  def default_media_type
117
- ENV['OCTOKIT_DEFAULT_MEDIA_TYPE'] || MEDIA_TYPE
117
+ ENV.fetch('OCTOKIT_DEFAULT_MEDIA_TYPE') { MEDIA_TYPE }
118
118
  end
119
119
 
120
120
  # Default GitHub username for Basic Auth from ENV
121
121
  # @return [String]
122
122
  def login
123
- ENV['OCTOKIT_LOGIN']
123
+ ENV.fetch('OCTOKIT_LOGIN', nil)
124
124
  end
125
125
 
126
126
  # Default middleware stack for Faraday::Connection
@@ -133,13 +133,13 @@ module Octokit
133
133
  # Default GitHub password for Basic Auth from ENV
134
134
  # @return [String]
135
135
  def password
136
- ENV['OCTOKIT_PASSWORD']
136
+ ENV.fetch('OCTOKIT_PASSWORD', nil)
137
137
  end
138
138
 
139
139
  # Default pagination page size from ENV
140
140
  # @return [Integer] Page size
141
141
  def per_page
142
- page_size = ENV['OCTOKIT_PER_PAGE']
142
+ page_size = ENV.fetch('OCTOKIT_PER_PAGE', nil)
143
143
 
144
144
  page_size&.to_i
145
145
  end
@@ -147,7 +147,7 @@ module Octokit
147
147
  # Default proxy server URI for Faraday connection from ENV
148
148
  # @return [String]
149
149
  def proxy
150
- ENV['OCTOKIT_PROXY']
150
+ ENV.fetch('OCTOKIT_PROXY', nil)
151
151
  end
152
152
 
153
153
  # Default SSL verify mode from ENV
@@ -162,25 +162,25 @@ module Octokit
162
162
  # Default User-Agent header string from ENV or {USER_AGENT}
163
163
  # @return [String]
164
164
  def user_agent
165
- ENV['OCTOKIT_USER_AGENT'] || USER_AGENT
165
+ ENV.fetch('OCTOKIT_USER_AGENT') { USER_AGENT }
166
166
  end
167
167
 
168
168
  # Default web endpoint from ENV or {WEB_ENDPOINT}
169
169
  # @return [String]
170
170
  def web_endpoint
171
- ENV['OCTOKIT_WEB_ENDPOINT'] || WEB_ENDPOINT
171
+ ENV.fetch('OCTOKIT_WEB_ENDPOINT') { WEB_ENDPOINT }
172
172
  end
173
173
 
174
174
  # Default behavior for reading .netrc file
175
175
  # @return [Boolean]
176
176
  def netrc
177
- ENV['OCTOKIT_NETRC'] || false
177
+ ENV.fetch('OCTOKIT_NETRC', false)
178
178
  end
179
179
 
180
180
  # Default path for .netrc file
181
181
  # @return [String]
182
182
  def netrc_file
183
- ENV['OCTOKIT_NETRC_FILE'] || File.join(ENV['HOME'].to_s, '.netrc')
183
+ ENV.fetch('OCTOKIT_NETRC_FILE') { File.join(Dir.home.to_s, '.netrc') }
184
184
  end
185
185
  end
186
186
  end
data/lib/octokit/error.rb CHANGED
@@ -4,6 +4,7 @@ module Octokit
4
4
  # Custom error class for rescuing from all GitHub errors
5
5
  class Error < StandardError
6
6
  attr_reader :context
7
+
7
8
  # Returns the appropriate Octokit::Error subclass based
8
9
  # on status and response message
9
10
  #
@@ -57,7 +58,9 @@ module Octokit
57
58
 
58
59
  # Returns most appropriate error for 401 HTTP status code
59
60
  # @private
61
+ # rubocop:disable Naming/VariableNumber
60
62
  def self.error_for_401(headers)
63
+ # rubocop:enbale Naming/VariableNumber
61
64
  if Octokit::OneTimePasswordRequired.required_header(headers)
62
65
  Octokit::OneTimePasswordRequired
63
66
  else
@@ -68,27 +71,27 @@ module Octokit
68
71
  # Returns most appropriate error for 403 HTTP status code
69
72
  # @private
70
73
  def self.error_for_403(body)
71
- if body =~ /rate limit exceeded/i
72
- Octokit::TooManyRequests
73
- elsif body =~ /exceeded a secondary rate limit/i
74
+ # rubocop:enable Naming/VariableNumber
75
+ case body
76
+ when /rate limit exceeded/i, /exceeded a secondary rate limit/i
74
77
  Octokit::TooManyRequests
75
- elsif body =~ /login attempts exceeded/i
78
+ when /login attempts exceeded/i
76
79
  Octokit::TooManyLoginAttempts
77
- elsif body =~ /returns blobs up to [0-9]+ MB/i
80
+ when /returns blobs up to [0-9]+ MB/i
78
81
  Octokit::TooLargeContent
79
- elsif body =~ /abuse/i
82
+ when /abuse/i
80
83
  Octokit::AbuseDetected
81
- elsif body =~ /repository access blocked/i
84
+ when /repository access blocked/i
82
85
  Octokit::RepositoryUnavailable
83
- elsif body =~ /email address must be verified/i
86
+ when /email address must be verified/i
84
87
  Octokit::UnverifiedEmail
85
- elsif body =~ /account was suspended/i
88
+ when /account was suspended/i
86
89
  Octokit::AccountSuspended
87
- elsif body =~ /billing issue/i
90
+ when /billing issue/i
88
91
  Octokit::BillingIssue
89
- elsif body =~ /Resource protected by organization SAML enforcement/i
92
+ when /Resource protected by organization SAML enforcement/i
90
93
  Octokit::SAMLProtected
91
- elsif body =~ /suspended your access|This installation has been suspended/i
94
+ when /suspended your access|This installation has been suspended/i
92
95
  Octokit::InstallationSuspended
93
96
  else
94
97
  Octokit::Forbidden
@@ -97,7 +100,9 @@ module Octokit
97
100
 
98
101
  # Return most appropriate error for 404 HTTP status code
99
102
  # @private
103
+ # rubocop:disable Naming/VariableNumber
100
104
  def self.error_for_404(body)
105
+ # rubocop:enable Naming/VariableNumber
101
106
  if body =~ /Branch not protected/i
102
107
  Octokit::BranchNotProtected
103
108
  else
@@ -107,7 +112,9 @@ module Octokit
107
112
 
108
113
  # Return most appropriate error for 422 HTTP status code
109
114
  # @private
115
+ # rubocop:disable Naming/VariableNumber
110
116
  def self.error_for_422(body)
117
+ # rubocop:enable Naming/VariableNumber
111
118
  if body =~ /PullRequestReviewComment/i && body =~ /(commit_id|end_commit_oid) is not part of the pull request/i
112
119
  Octokit::CommitIsNotPartOfPullRequest
113
120
  elsif body =~ /Path diff too large/i
@@ -120,7 +127,7 @@ module Octokit
120
127
  # Array of validation errors
121
128
  # @return [Array<Hash>] Error info
122
129
  def errors
123
- if data&.is_a?(Hash)
130
+ if data.is_a?(Hash)
124
131
  data[:errors] || []
125
132
  else
126
133
  []
@@ -196,7 +203,7 @@ module Octokit
196
203
  return nil if @response.nil?
197
204
 
198
205
  message = +"#{@response[:method].to_s.upcase} "
199
- message << redact_url(@response[:url].to_s.dup) + ': '
206
+ message << "#{redact_url(@response[:url].to_s.dup)}: "
200
207
  message << "#{@response[:status]} - "
201
208
  message << response_message.to_s unless response_message.nil?
202
209
  message << response_error.to_s unless response_error.nil?
@@ -127,7 +127,7 @@ module Octokit
127
127
  # risk double-escaping.
128
128
  def safe_escape(uri)
129
129
  uri.to_s.gsub(URI_UNSAFE) do |match|
130
- '%' + match.unpack('H2' * match.bytesize).join('%').upcase
130
+ "%#{match.unpack('H2' * match.bytesize).join('%').upcase}"
131
131
  end
132
132
  end
133
133
  end
@@ -20,7 +20,7 @@ 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?
23
+ if 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)
@@ -5,6 +5,7 @@ module Octokit
5
5
  # URLs and to generate URLs
6
6
  class Repository
7
7
  attr_accessor :owner, :name, :id
8
+
8
9
  NAME_WITH_OWNER_PATTERN = %r{\A[\w.-]+/[\w.-]+\z}i.freeze
9
10
 
10
11
  # Instantiate from a GitHub repository URL
@@ -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: 5.0.0
4
+ version: 5.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-07-12 00:00:00.000000000 Z
13
+ date: 2022-07-13 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: bundler
@@ -86,6 +86,7 @@ files:
86
86
  - lib/octokit/authentication.rb
87
87
  - lib/octokit/client.rb
88
88
  - lib/octokit/client/actions_secrets.rb
89
+ - lib/octokit/client/actions_workflow_jobs.rb
89
90
  - lib/octokit/client/actions_workflow_runs.rb
90
91
  - lib/octokit/client/actions_workflows.rb
91
92
  - lib/octokit/client/apps.rb