dependabot-common 0.156.4 → 0.156.8

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: e39eee9a89b619ae11edbb045c99a8a88f7e8a1a3e494a655e0a35aa6aa58644
4
- data.tar.gz: d4c75ce73b32e2e03afb8164e09158373a1fb5fad84ed0ae56da66898eef8b25
3
+ metadata.gz: a228900d547d72f07db549728cf5d29e610ac89d623f41ffef4b69903a93692d
4
+ data.tar.gz: 5907cbcfe731accd8c0be129b894e96efd3f4d2ab0407e0d5accd380c46e73c9
5
5
  SHA512:
6
- metadata.gz: '041844a828047dacf14e985628f69315038f823792581e7fd5f3cada10d5521f650139c099aef6c106042d20341b1959d7edad22f9e9d653f5d346e3e8f41b6c'
7
- data.tar.gz: b404559550ecc79d654a6ebbcfc35cc9116ae775749bc34883d00217f782539ed4ef44f0eaf27dda28fe37ddeb21fe32ae7176caa4ea9a5fd04981970c9c7fa9
6
+ metadata.gz: 5e541559edf31b7567d2b3f84277ae1db8bad6c3675f12e1ba1286c285f6a679920f3f56e0128394aecb50f4a491cba3e754349235e59d0d02334a39b62adc2e
7
+ data.tar.gz: a31eda6e8d5d4fab9e7bf1c602532b1bf3f8b63935c18e1ded6432096884aaac249e6a478cad5ac83f79f69b95c8945511fc6c205162e811004fc6ce51ebba65
@@ -14,6 +14,10 @@ module Dependabot
14
14
 
15
15
  class BadGateway < StandardError; end
16
16
 
17
+ class Unauthorized < StandardError; end
18
+
19
+ class Forbidden < StandardError; end
20
+
17
21
  RETRYABLE_ERRORS = [InternalServerError, BadGateway, ServiceNotAvailable].freeze
18
22
 
19
23
  MAX_PR_DESCRIPTION_LENGTH = 3999
@@ -228,6 +232,8 @@ module Dependabot
228
232
  raise ServiceNotAvailable if response.status == 503
229
233
  end
230
234
 
235
+ raise Unauthorized if response.status == 401
236
+ raise Forbidden if response.status == 403
231
237
  raise NotFound if response.status == 404
232
238
 
233
239
  response
@@ -257,6 +263,8 @@ module Dependabot
257
263
  raise ServiceNotAvailable if response.status == 503
258
264
  end
259
265
 
266
+ raise Unauthorized if response.status == 401
267
+ raise Forbidden if response.status == 403
260
268
  raise NotFound if response.status == 404
261
269
 
262
270
  response
@@ -157,11 +157,12 @@ module Dependabot
157
157
  path = Pathname.new(File.join(dir)).cleanpath.to_path.gsub(%r{^/*}, "")
158
158
 
159
159
  @repo_contents ||= {}
160
- @repo_contents[dir] ||= _fetch_repo_contents(
161
- path,
162
- raise_errors: raise_errors,
163
- fetch_submodules: fetch_submodules
164
- )
160
+ @repo_contents[dir] ||= if repo_contents_path
161
+ _cloned_repo_contents(path)
162
+ else
163
+ _fetch_repo_contents(path, raise_errors: raise_errors,
164
+ fetch_submodules: fetch_submodules)
165
+ end
165
166
  end
166
167
 
167
168
  #################################################
@@ -225,6 +226,31 @@ module Dependabot
225
226
  github_response.map { |f| _build_github_file_struct(f) }
226
227
  end
227
228
 
229
+ def _cloned_repo_contents(relative_path)
230
+ repo_path = File.join(clone_repo_contents, relative_path)
231
+ return [] unless Dir.exist?(repo_path)
232
+
233
+ Dir.entries(repo_path).map do |name|
234
+ next if [".", ".."].include?(name)
235
+
236
+ absolute_path = File.join(repo_path, name)
237
+ type = if File.symlink?(absolute_path)
238
+ "symlink"
239
+ elsif Dir.exist?(absolute_path)
240
+ "dir"
241
+ else
242
+ "file"
243
+ end
244
+
245
+ OpenStruct.new(
246
+ name: name,
247
+ path: Pathname.new(File.join(relative_path, name)).cleanpath.to_path,
248
+ type: type,
249
+ size: 0 # NOTE: added for parity with github contents API
250
+ )
251
+ end.compact
252
+ end
253
+
228
254
  def update_linked_paths(repo, path, commit, github_response)
229
255
  case github_response.type
230
256
  when "submodule"
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Dependabot
4
- VERSION = "0.156.4"
4
+ VERSION = "0.156.8"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-common
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.156.4
4
+ version: 0.156.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-06-30 00:00:00.000000000 Z
11
+ date: 2021-07-15 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -469,7 +469,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
469
469
  - !ruby/object:Gem::Version
470
470
  version: 2.7.3
471
471
  requirements: []
472
- rubygems_version: 3.2.15
472
+ rubygems_version: 3.2.22
473
473
  signing_key:
474
474
  specification_version: 4
475
475
  summary: Shared code used between Dependabot package managers