dependabot-common 0.244.0 → 0.245.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: 7aa21cb81796cffb973cf4ff58644678588c40d9c6efc0cd81d514a3a894cbce
4
- data.tar.gz: b786777a6d7509b002bdef262c441197dad93a31767599885e2202b299040b2e
3
+ metadata.gz: fbc9b9fbba7549f6bdbb7dafec2f3d3111bd2e8263e966b3eaf1bfce19be3a01
4
+ data.tar.gz: 2e396338454b56410104329634792a20076533cadf2418f15e74d591612969eb
5
5
  SHA512:
6
- metadata.gz: 78eb059c3184e4329102ffb76b91339bb42ec740a97c622f4c1a67d5694c14fb0b44a40c08b6fba5e4712b0a83a9d745b099ec7685e8eb95f667a670625345a5
7
- data.tar.gz: 7c08bebb791070f134fbc4b40c3cff32431fb6342f02137e5803bb6f2439bfdf5f199f5b5b71e99d9398842da38b5f6c84eb5e0c61912f8212352052321da888
6
+ metadata.gz: 2cc3166e278f88f679a7d177b74d77ba9d8cd48ac22694db65a61a36bf5386efb7fd459e430f971cad2e21f33253e67f1e264137fcfc48b57d3d41480c71f9f9
7
+ data.tar.gz: fc85175d8dfe6020bc3737fec46342fe529371e984d0f1d806195c697124ff6c63418edc7a1135a30c1c2ceff6caf28be2a715463c466c6bfa3267b5b0249b8a
@@ -1,4 +1,4 @@
1
- # typed: true
1
+ # typed: strict
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require_relative "bitbucket"
@@ -6,15 +6,18 @@ require_relative "bitbucket"
6
6
  module Dependabot
7
7
  module Clients
8
8
  class BitbucketWithRetries
9
- RETRYABLE_ERRORS = [
10
- Excon::Error::Timeout,
11
- Excon::Error::Socket
12
- ].freeze
9
+ extend T::Sig
10
+
11
+ RETRYABLE_ERRORS = T.let(
12
+ [Excon::Error::Timeout, Excon::Error::Socket].freeze,
13
+ T::Array[T.class_of(Excon::Error)]
14
+ )
13
15
 
14
16
  #######################
15
17
  # Constructor methods #
16
18
  #######################
17
19
 
20
+ sig { params(credentials: T::Array[Dependabot::Credential]).returns(BitbucketWithRetries) }
18
21
  def self.for_bitbucket_dot_org(credentials:)
19
22
  credential =
20
23
  credentials
@@ -28,27 +31,48 @@ module Dependabot
28
31
  # Proxying #
29
32
  ############
30
33
 
31
- def initialize(max_retries: 3, **args)
32
- @max_retries = max_retries || 3
33
- @client = Bitbucket.new(**T.unsafe(args))
34
+ sig { params(credentials: T.nilable(Dependabot::Credential), max_retries: T.nilable(Integer)).void }
35
+ def initialize(credentials:, max_retries: 3)
36
+ @max_retries = T.let(max_retries || 3, Integer)
37
+ @client = T.let(Bitbucket.new(credentials: credentials), Dependabot::Clients::Bitbucket)
34
38
  end
35
39
 
40
+ sig do
41
+ params(
42
+ method_name: T.any(Symbol, String),
43
+ args: T.untyped,
44
+ block: T.nilable(T.proc.returns(T.untyped))
45
+ )
46
+ .returns(T.untyped)
47
+ end
36
48
  def method_missing(method_name, *args, &block)
37
49
  retry_connection_failures do
38
50
  if @client.respond_to?(method_name)
39
51
  mutatable_args = args.map(&:dup)
40
- @client.public_send(method_name, *mutatable_args, &block)
52
+ T.unsafe(@client).public_send(method_name, *mutatable_args, &block)
41
53
  else
42
54
  super
43
55
  end
44
56
  end
45
57
  end
46
58
 
59
+ sig do
60
+ params(
61
+ method_name: Symbol,
62
+ include_private: T::Boolean
63
+ )
64
+ .returns(T::Boolean)
65
+ end
47
66
  def respond_to_missing?(method_name, include_private = false)
48
67
  @client.respond_to?(method_name) || super
49
68
  end
50
69
 
51
- def retry_connection_failures
70
+ sig do
71
+ type_parameters(:T)
72
+ .params(_blk: T.proc.returns(T.type_parameter(:T)))
73
+ .returns(T.type_parameter(:T))
74
+ end
75
+ def retry_connection_failures(&_blk)
52
76
  retry_attempt = 0
53
77
 
54
78
  begin
@@ -393,7 +393,7 @@ module Dependabot
393
393
  client = Clients::BitbucketWithRetries
394
394
  .for_bitbucket_dot_org(credentials: credentials)
395
395
 
396
- response = client.get(url)
396
+ response = T.unsafe(client).get(url)
397
397
 
398
398
  # Conservatively assume that ref2 is ahead in the equality case, of
399
399
  # if we get an unexpected format (e.g., due to a 404)
@@ -405,7 +405,6 @@ module Dependabot
405
405
  stderr_to_stdout: true)
406
406
  start = Time.now
407
407
  cmd = allow_unsafe_shell_command ? command : escape_command(command)
408
-
409
408
  if stderr_to_stdout
410
409
  stdout, process = Open3.capture2e(env || {}, cmd)
411
410
  else
@@ -425,12 +424,31 @@ module Dependabot
425
424
  process_exit_value: process.to_s
426
425
  }
427
426
 
427
+ check_out_of_disk_memory_error(stderr, error_context)
428
+
428
429
  raise SharedHelpers::HelperSubprocessFailed.new(
429
430
  message: stderr_to_stdout ? stdout : "#{stderr}\n#{stdout}",
430
431
  error_context: error_context
431
432
  )
432
433
  end
433
434
 
435
+ sig { params(stderr: T.nilable(String), error_context: T::Hash[Symbol, String]).void }
436
+ def self.check_out_of_disk_memory_error(stderr, error_context)
437
+ if stderr&.include?("No space left on device") || stderr&.include?("Out of diskspace")
438
+ raise HelperSubprocessFailed.new(
439
+ message: "No space left on device",
440
+ error_class: "Dependabot::OutOfDisk",
441
+ error_context: error_context
442
+ )
443
+ elsif stderr&.include?("MemoryError")
444
+ raise HelperSubprocessFailed.new(
445
+ message: "MemoryError",
446
+ error_class: "Dependabot::OutOfMemory",
447
+ error_context: error_context
448
+ )
449
+ end
450
+ end
451
+
434
452
  sig { params(command: String, stdin_data: String, env: T.nilable(T::Hash[String, String])).returns(String) }
435
453
  def self.helper_subprocess_bash_command(command:, stdin_data:, env:)
436
454
  escaped_stdin_data = stdin_data.gsub("\"", "\\\"")
data/lib/dependabot.rb CHANGED
@@ -2,5 +2,5 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  module Dependabot
5
- VERSION = "0.244.0"
5
+ VERSION = "0.245.0"
6
6
  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.244.0
4
+ version: 0.245.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-02-15 00:00:00.000000000 Z
11
+ date: 2024-02-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: aws-sdk-codecommit
@@ -567,7 +567,7 @@ licenses:
567
567
  - Nonstandard
568
568
  metadata:
569
569
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
570
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.244.0
570
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.245.0
571
571
  post_install_message:
572
572
  rdoc_options: []
573
573
  require_paths: