dependabot-common 0.244.0 → 0.246.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dependabot/clients/bitbucket.rb +113 -5
- data/lib/dependabot/clients/bitbucket_with_retries.rb +34 -10
- data/lib/dependabot/clients/codecommit.rb +107 -12
- data/lib/dependabot/clients/github_with_retries.rb +61 -19
- data/lib/dependabot/clients/gitlab_with_retries.rb +60 -7
- data/lib/dependabot/dependency.rb +1 -1
- data/lib/dependabot/errors.rb +8 -2
- data/lib/dependabot/git_commit_checker.rb +4 -3
- data/lib/dependabot/metadata_finders/base/changelog_finder.rb +1 -1
- data/lib/dependabot/metadata_finders/base/commits_finder.rb +1 -1
- data/lib/dependabot/metadata_finders/base/release_finder.rb +1 -1
- data/lib/dependabot/pull_request_creator/azure.rb +80 -9
- data/lib/dependabot/pull_request_creator/bitbucket.rb +73 -9
- data/lib/dependabot/pull_request_creator/codecommit.rb +96 -25
- data/lib/dependabot/pull_request_creator/github.rb +162 -49
- data/lib/dependabot/pull_request_creator/gitlab.rb +109 -21
- data/lib/dependabot/pull_request_creator/message_builder.rb +239 -89
- data/lib/dependabot/pull_request_creator/pr_name_prefixer.rb +11 -9
- data/lib/dependabot/pull_request_creator.rb +32 -27
- data/lib/dependabot/pull_request_updater/azure.rb +75 -11
- data/lib/dependabot/pull_request_updater/github.rb +89 -28
- data/lib/dependabot/pull_request_updater/gitlab.rb +61 -12
- data/lib/dependabot/pull_request_updater.rb +1 -1
- data/lib/dependabot/shared_helpers.rb +19 -1
- data/lib/dependabot/update_checkers/base.rb +121 -31
- data/lib/dependabot.rb +1 -1
- metadata +3 -3
@@ -1,16 +1,51 @@
|
|
1
|
-
# typed:
|
1
|
+
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
|
+
require "gitlab"
|
5
|
+
require "sorbet-runtime"
|
6
|
+
|
4
7
|
require "dependabot/clients/gitlab_with_retries"
|
8
|
+
require "dependabot/credential"
|
5
9
|
require "dependabot/pull_request_creator"
|
6
|
-
require "gitlab"
|
7
10
|
|
8
11
|
module Dependabot
|
9
12
|
class PullRequestUpdater
|
10
13
|
class Gitlab
|
11
|
-
|
12
|
-
|
14
|
+
extend T::Sig
|
15
|
+
|
16
|
+
sig { returns(Dependabot::Source) }
|
17
|
+
attr_reader :source
|
18
|
+
|
19
|
+
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
20
|
+
attr_reader :files
|
21
|
+
|
22
|
+
sig { returns(String) }
|
23
|
+
attr_reader :base_commit
|
13
24
|
|
25
|
+
sig { returns(String) }
|
26
|
+
attr_reader :old_commit
|
27
|
+
|
28
|
+
sig { returns(T::Array[Dependabot::Credential]) }
|
29
|
+
attr_reader :credentials
|
30
|
+
|
31
|
+
sig { returns(Integer) }
|
32
|
+
attr_reader :pull_request_number
|
33
|
+
|
34
|
+
sig { returns(T.nilable(Integer)) }
|
35
|
+
attr_reader :target_project_id
|
36
|
+
|
37
|
+
sig do
|
38
|
+
params(
|
39
|
+
source: Dependabot::Source,
|
40
|
+
base_commit: String,
|
41
|
+
old_commit: String,
|
42
|
+
files: T::Array[Dependabot::DependencyFile],
|
43
|
+
credentials: T::Array[Dependabot::Credential],
|
44
|
+
pull_request_number: Integer,
|
45
|
+
target_project_id: T.nilable(Integer)
|
46
|
+
)
|
47
|
+
.void
|
48
|
+
end
|
14
49
|
def initialize(source:, base_commit:, old_commit:, files:,
|
15
50
|
credentials:, pull_request_number:, target_project_id:)
|
16
51
|
@source = source
|
@@ -22,6 +57,7 @@ module Dependabot
|
|
22
57
|
@target_project_id = target_project_id
|
23
58
|
end
|
24
59
|
|
60
|
+
sig { returns(T.nilable(String)) }
|
25
61
|
def update
|
26
62
|
return unless merge_request_exists?
|
27
63
|
return unless branch_exists?(merge_request.source_branch)
|
@@ -32,6 +68,7 @@ module Dependabot
|
|
32
68
|
|
33
69
|
private
|
34
70
|
|
71
|
+
sig { returns(T::Boolean) }
|
35
72
|
def merge_request_exists?
|
36
73
|
merge_request
|
37
74
|
true
|
@@ -39,31 +76,43 @@ module Dependabot
|
|
39
76
|
false
|
40
77
|
end
|
41
78
|
|
79
|
+
sig { returns(T.untyped) }
|
42
80
|
def merge_request
|
43
|
-
@merge_request ||=
|
44
|
-
|
45
|
-
|
81
|
+
@merge_request ||= T.let(
|
82
|
+
T.unsafe(gitlab_client_for_source).merge_request(
|
83
|
+
target_project_id || source.repo,
|
84
|
+
pull_request_number
|
85
|
+
),
|
86
|
+
T.untyped
|
46
87
|
)
|
47
88
|
end
|
48
89
|
|
90
|
+
sig { returns(Dependabot::Clients::GitlabWithRetries) }
|
49
91
|
def gitlab_client_for_source
|
50
92
|
@gitlab_client_for_source ||=
|
51
|
-
|
52
|
-
|
53
|
-
|
93
|
+
T.let(
|
94
|
+
Dependabot::Clients::GitlabWithRetries.for_source(
|
95
|
+
source: source,
|
96
|
+
credentials: credentials
|
97
|
+
),
|
98
|
+
T.nilable(Dependabot::Clients::GitlabWithRetries)
|
54
99
|
)
|
55
100
|
end
|
56
101
|
|
102
|
+
sig { params(name: String).returns(T::Boolean) }
|
57
103
|
def branch_exists?(name)
|
58
|
-
gitlab_client_for_source.branch(source.repo, name)
|
104
|
+
!T.unsafe(gitlab_client_for_source).branch(source.repo, name).nil?
|
59
105
|
rescue ::Gitlab::Error::NotFound
|
60
106
|
false
|
61
107
|
end
|
62
108
|
|
109
|
+
# TODO: This needs to be typed when the underlying client is
|
110
|
+
sig { returns(T.untyped) }
|
63
111
|
def commit_being_updated
|
64
|
-
gitlab_client_for_source.commit(source.repo, old_commit)
|
112
|
+
T.unsafe(gitlab_client_for_source).commit(source.repo, old_commit)
|
65
113
|
end
|
66
114
|
|
115
|
+
sig { void }
|
67
116
|
def create_commit
|
68
117
|
gitlab_client_for_source.create_commit(
|
69
118
|
source.repo,
|
@@ -106,7 +106,7 @@ module Dependabot
|
|
106
106
|
files: files,
|
107
107
|
credentials: credentials,
|
108
108
|
pull_request_number: pull_request_number,
|
109
|
-
target_project_id: provider_metadata[:target_project_id]
|
109
|
+
target_project_id: T.cast(provider_metadata[:target_project_id], T.nilable(Integer))
|
110
110
|
)
|
111
111
|
end
|
112
112
|
|
@@ -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("\"", "\\\"")
|
@@ -1,20 +1,65 @@
|
|
1
|
-
# typed:
|
1
|
+
# typed: strict
|
2
2
|
# frozen_string_literal: true
|
3
3
|
|
4
4
|
require "json"
|
5
|
+
require "sorbet-runtime"
|
6
|
+
|
5
7
|
require "dependabot/utils"
|
6
8
|
require "dependabot/security_advisory"
|
7
9
|
|
8
10
|
module Dependabot
|
9
11
|
module UpdateCheckers
|
10
12
|
class Base
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
13
|
+
extend T::Sig
|
14
|
+
extend T::Helpers
|
15
|
+
|
16
|
+
sig { returns(Dependabot::Dependency) }
|
17
|
+
attr_reader :dependency
|
18
|
+
|
19
|
+
sig { returns(T::Array[Dependabot::DependencyFile]) }
|
20
|
+
attr_reader :dependency_files
|
21
|
+
|
22
|
+
sig { returns(T.nilable(String)) }
|
23
|
+
attr_reader :repo_contents_path
|
24
|
+
|
25
|
+
sig { returns(T::Array[Dependabot::Credential]) }
|
26
|
+
attr_reader :credentials
|
27
|
+
|
28
|
+
sig { returns(T::Array[String]) }
|
29
|
+
attr_reader :ignored_versions
|
30
|
+
|
31
|
+
sig { returns(T::Boolean) }
|
32
|
+
attr_reader :raise_on_ignored
|
33
|
+
|
34
|
+
sig { returns(T::Array[Dependabot::SecurityAdvisory]) }
|
35
|
+
attr_reader :security_advisories
|
36
|
+
|
37
|
+
sig { returns(T.nilable(Symbol)) }
|
38
|
+
attr_reader :requirements_update_strategy
|
39
|
+
|
40
|
+
sig { returns(T.nilable(Dependabot::DependencyGroup)) }
|
41
|
+
attr_reader :dependency_group
|
42
|
+
|
43
|
+
sig { returns(T::Hash[Symbol, T.untyped]) }
|
44
|
+
attr_reader :options
|
15
45
|
|
16
|
-
|
17
|
-
|
46
|
+
sig do
|
47
|
+
params(
|
48
|
+
dependency: Dependabot::Dependency,
|
49
|
+
dependency_files: T::Array[Dependabot::DependencyFile],
|
50
|
+
credentials: T::Array[Dependabot::Credential],
|
51
|
+
repo_contents_path: T.nilable(String),
|
52
|
+
ignored_versions: T::Array[String],
|
53
|
+
raise_on_ignored: T::Boolean,
|
54
|
+
security_advisories: T::Array[Dependabot::SecurityAdvisory],
|
55
|
+
requirements_update_strategy: T.nilable(Symbol),
|
56
|
+
dependency_group: T.nilable(Dependabot::DependencyGroup),
|
57
|
+
options: T::Hash[Symbol, T.untyped]
|
58
|
+
)
|
59
|
+
.void
|
60
|
+
end
|
61
|
+
def initialize(dependency:, dependency_files:, credentials:,
|
62
|
+
repo_contents_path: nil, ignored_versions: [],
|
18
63
|
raise_on_ignored: false, security_advisories: [],
|
19
64
|
requirements_update_strategy: nil, dependency_group: nil,
|
20
65
|
options: {})
|
@@ -30,6 +75,7 @@ module Dependabot
|
|
30
75
|
@options = options
|
31
76
|
end
|
32
77
|
|
78
|
+
sig { returns(T::Boolean) }
|
33
79
|
def up_to_date?
|
34
80
|
if dependency.version
|
35
81
|
version_up_to_date?
|
@@ -38,6 +84,7 @@ module Dependabot
|
|
38
84
|
end
|
39
85
|
end
|
40
86
|
|
87
|
+
sig { params(requirements_to_unlock: T.nilable(Symbol)).returns(T::Boolean) }
|
41
88
|
def can_update?(requirements_to_unlock:)
|
42
89
|
# Can't update if all versions are being ignored
|
43
90
|
return false if ignore_requirements.include?(requirement_class.new(">= 0"))
|
@@ -52,6 +99,7 @@ module Dependabot
|
|
52
99
|
end
|
53
100
|
end
|
54
101
|
|
102
|
+
sig { params(requirements_to_unlock: T.nilable(Symbol)).returns(T::Array[Dependabot::Dependency]) }
|
55
103
|
def updated_dependencies(requirements_to_unlock:)
|
56
104
|
return [] unless can_update?(requirements_to_unlock: requirements_to_unlock)
|
57
105
|
|
@@ -63,10 +111,12 @@ module Dependabot
|
|
63
111
|
end
|
64
112
|
end
|
65
113
|
|
114
|
+
sig { overridable.returns(T.nilable(T.any(String, Gem::Version))) }
|
66
115
|
def latest_version
|
67
|
-
raise NotImplementedError
|
116
|
+
raise NotImplementedError, "#{self.class} must implement #latest_version"
|
68
117
|
end
|
69
118
|
|
119
|
+
sig { overridable.returns(T.nilable(T.any(String, Gem::Version))) }
|
70
120
|
def preferred_resolvable_version
|
71
121
|
# If this dependency is vulnerable, prefer trying to update to the
|
72
122
|
# lowest_resolvable_security_fix_version. Otherwise update all the way
|
@@ -78,22 +128,26 @@ module Dependabot
|
|
78
128
|
latest_resolvable_version
|
79
129
|
end
|
80
130
|
|
131
|
+
sig { overridable.returns(T.nilable(T.any(String, Gem::Version))) }
|
81
132
|
def latest_resolvable_version
|
82
|
-
raise NotImplementedError
|
133
|
+
raise NotImplementedError, "#{self.class} must implement #latest_resolvable_version"
|
83
134
|
end
|
84
135
|
|
85
136
|
# Lowest available security fix version not checking resolvability
|
86
137
|
# @return [Dependabot::<package manager>::Version, #to_s] version class
|
138
|
+
sig { overridable.returns(Dependabot::Version) }
|
87
139
|
def lowest_security_fix_version
|
88
|
-
raise NotImplementedError
|
140
|
+
raise NotImplementedError, "#{self.class} must implement #lowest_security_fix_version"
|
89
141
|
end
|
90
142
|
|
143
|
+
sig { overridable.returns(String) }
|
91
144
|
def lowest_resolvable_security_fix_version
|
92
|
-
raise NotImplementedError
|
145
|
+
raise NotImplementedError, "#{self.class} must implement #lowest_resolvable_security_fix_version"
|
93
146
|
end
|
94
147
|
|
148
|
+
sig { overridable.returns(T.nilable(T.any(String, Dependabot::Version))) }
|
95
149
|
def latest_resolvable_version_with_no_unlock
|
96
|
-
raise NotImplementedError
|
150
|
+
raise NotImplementedError, "#{self.class} must implement #latest_resolvable_version_with_no_unlock"
|
97
151
|
end
|
98
152
|
|
99
153
|
# Finds any dependencies in the lockfile that have a subdependency on the
|
@@ -102,22 +156,27 @@ module Dependabot
|
|
102
156
|
# name [String] the blocking dependencies name
|
103
157
|
# version [String] the version of the blocking dependency
|
104
158
|
# requirement [String] the requirement on the target_dependency
|
159
|
+
sig { overridable.returns(T::Array[T::Hash[String, String]]) }
|
105
160
|
def conflicting_dependencies
|
106
161
|
[] # return an empty array for ecosystems that don't support this yet
|
107
162
|
end
|
108
163
|
|
164
|
+
sig { params(_updated_version: String).returns(T.nilable(String)) }
|
109
165
|
def latest_resolvable_previous_version(_updated_version)
|
110
166
|
dependency.version
|
111
167
|
end
|
112
168
|
|
169
|
+
sig { overridable.returns(T::Array[T::Hash[Symbol, T.untyped]]) }
|
113
170
|
def updated_requirements
|
114
171
|
raise NotImplementedError
|
115
172
|
end
|
116
173
|
|
174
|
+
sig { returns(T.class_of(Dependabot::Version)) }
|
117
175
|
def version_class
|
118
176
|
dependency.version_class
|
119
177
|
end
|
120
178
|
|
179
|
+
sig { returns(T.class_of(Dependabot::Requirement)) }
|
121
180
|
def requirement_class
|
122
181
|
dependency.requirement_class
|
123
182
|
end
|
@@ -125,10 +184,12 @@ module Dependabot
|
|
125
184
|
# For some languages, the manifest file may be constructed such that
|
126
185
|
# Dependabot has no way to update it (e.g., if it fetches its versions
|
127
186
|
# from a web API). This method is overridden in those cases.
|
187
|
+
sig { returns(T::Boolean) }
|
128
188
|
def requirements_unlocked_or_can_be?
|
129
189
|
true
|
130
190
|
end
|
131
191
|
|
192
|
+
sig { returns(T::Boolean) }
|
132
193
|
def vulnerable?
|
133
194
|
return false if security_advisories.none?
|
134
195
|
|
@@ -142,20 +203,24 @@ module Dependabot
|
|
142
203
|
active_advisories.any?
|
143
204
|
end
|
144
205
|
|
206
|
+
sig { returns(T::Array[Dependabot::Requirement]) }
|
145
207
|
def ignore_requirements
|
146
208
|
ignored_versions.flat_map { |req| requirement_class.requirements_array(req) }
|
147
209
|
end
|
148
210
|
|
149
211
|
private
|
150
212
|
|
213
|
+
sig { returns(T::Array[Dependabot::SecurityAdvisory]) }
|
151
214
|
def active_advisories
|
152
|
-
security_advisories.select { |a| a.vulnerable?(current_version) }
|
215
|
+
security_advisories.select { |a| a.vulnerable?(T.must(current_version)) }
|
153
216
|
end
|
154
217
|
|
218
|
+
sig { overridable.returns(T::Boolean) }
|
155
219
|
def latest_version_resolvable_with_full_unlock?
|
156
|
-
raise NotImplementedError
|
220
|
+
raise NotImplementedError, "#{self.class} must implement #latest_version_resolvable_with_full_unlock?"
|
157
221
|
end
|
158
222
|
|
223
|
+
sig { returns(Dependabot::Dependency) }
|
159
224
|
def updated_dependency_without_unlock
|
160
225
|
version = latest_resolvable_version_with_no_unlock.to_s
|
161
226
|
previous_version = latest_resolvable_previous_version(version)&.to_s
|
@@ -172,6 +237,7 @@ module Dependabot
|
|
172
237
|
)
|
173
238
|
end
|
174
239
|
|
240
|
+
sig { returns(Dependabot::Dependency) }
|
175
241
|
def updated_dependency_with_own_req_unlock
|
176
242
|
version = preferred_resolvable_version.to_s
|
177
243
|
previous_version = latest_resolvable_previous_version(version)&.to_s
|
@@ -188,16 +254,19 @@ module Dependabot
|
|
188
254
|
)
|
189
255
|
end
|
190
256
|
|
257
|
+
sig { overridable.returns(T::Array[Dependabot::Dependency]) }
|
191
258
|
def updated_dependencies_after_full_unlock
|
192
259
|
raise NotImplementedError
|
193
260
|
end
|
194
261
|
|
262
|
+
sig { returns(T::Boolean) }
|
195
263
|
def version_up_to_date?
|
196
264
|
return sha1_version_up_to_date? if existing_version_is_sha?
|
197
265
|
|
198
266
|
numeric_version_up_to_date?
|
199
267
|
end
|
200
268
|
|
269
|
+
sig { params(requirements_to_unlock: T.nilable(Symbol)).returns(T::Boolean) }
|
201
270
|
def version_can_update?(requirements_to_unlock:)
|
202
271
|
if existing_version_is_sha?
|
203
272
|
return sha1_version_can_update?(
|
@@ -210,16 +279,19 @@ module Dependabot
|
|
210
279
|
)
|
211
280
|
end
|
212
281
|
|
282
|
+
sig { returns(T::Boolean) }
|
213
283
|
def existing_version_is_sha?
|
214
284
|
return false if version_class.correct?(dependency.version)
|
215
285
|
|
216
|
-
dependency.version.match?(/^[0-9a-f]{6,}$/)
|
286
|
+
T.must(dependency.version).match?(/^[0-9a-f]{6,}$/)
|
217
287
|
end
|
218
288
|
|
289
|
+
sig { returns(T::Boolean) }
|
219
290
|
def sha1_version_up_to_date?
|
220
|
-
latest_version&.to_s&.start_with?(dependency.version)
|
291
|
+
latest_version&.to_s&.start_with?(T.must(dependency.version)) || false
|
221
292
|
end
|
222
293
|
|
294
|
+
sig { params(requirements_to_unlock: T.nilable(Symbol)).returns(T::Boolean) }
|
223
295
|
def sha1_version_can_update?(requirements_to_unlock:)
|
224
296
|
return false if sha1_version_up_to_date?
|
225
297
|
|
@@ -227,7 +299,7 @@ module Dependabot
|
|
227
299
|
case requirements_to_unlock&.to_sym
|
228
300
|
when :none
|
229
301
|
new_version = latest_resolvable_version_with_no_unlock
|
230
|
-
|
302
|
+
!new_version&.to_s&.start_with?(T.must(dependency.version))
|
231
303
|
when :own
|
232
304
|
preferred_version_resolvable_with_unlock?
|
233
305
|
when :all
|
@@ -236,6 +308,7 @@ module Dependabot
|
|
236
308
|
end
|
237
309
|
end
|
238
310
|
|
311
|
+
sig { returns(T::Boolean) }
|
239
312
|
def numeric_version_up_to_date?
|
240
313
|
return false unless latest_version
|
241
314
|
|
@@ -244,16 +317,19 @@ module Dependabot
|
|
244
317
|
# this case we treat the version as up-to-date so that it's ignored.
|
245
318
|
return true if latest_version.to_s.match?(/^[0-9a-f]{40}$/)
|
246
319
|
|
247
|
-
latest_version <= current_version
|
320
|
+
T.must(latest_version) <= current_version
|
248
321
|
end
|
249
322
|
|
323
|
+
sig { params(requirements_to_unlock: T.nilable(Symbol)).returns(T::Boolean) }
|
250
324
|
def numeric_version_can_update?(requirements_to_unlock:)
|
251
325
|
return false if numeric_version_up_to_date?
|
252
326
|
|
253
327
|
case requirements_to_unlock&.to_sym
|
254
328
|
when :none
|
255
329
|
new_version = latest_resolvable_version_with_no_unlock
|
256
|
-
|
330
|
+
return false unless new_version
|
331
|
+
|
332
|
+
new_version > current_version
|
257
333
|
when :own
|
258
334
|
preferred_version_resolvable_with_unlock?
|
259
335
|
when :all
|
@@ -262,12 +338,13 @@ module Dependabot
|
|
262
338
|
end
|
263
339
|
end
|
264
340
|
|
341
|
+
sig { returns(T::Boolean) }
|
265
342
|
def preferred_version_resolvable_with_unlock?
|
266
343
|
new_version = preferred_resolvable_version
|
267
344
|
return false unless new_version
|
268
345
|
|
269
346
|
if existing_version_is_sha?
|
270
|
-
return false if new_version.to_s.start_with?(dependency.version)
|
347
|
+
return false if new_version.to_s.start_with?(T.must(dependency.version))
|
271
348
|
elsif new_version <= current_version
|
272
349
|
return false
|
273
350
|
end
|
@@ -275,39 +352,52 @@ module Dependabot
|
|
275
352
|
updated_requirements.none? { |r| r[:requirement] == :unfixable }
|
276
353
|
end
|
277
354
|
|
355
|
+
sig { returns(T::Boolean) }
|
278
356
|
def requirements_up_to_date?
|
279
357
|
if can_compare_requirements?
|
280
|
-
return (version_from_requirements >=
|
281
|
-
version_class.new(latest_version.to_s))
|
358
|
+
return (T.must(version_from_requirements) >= version_class.new(latest_version.to_s))
|
282
359
|
end
|
283
360
|
|
284
361
|
changed_requirements.none?
|
285
362
|
end
|
286
363
|
|
364
|
+
# TODO: Should this return Dependabot::Version?
|
365
|
+
sig { returns(T.nilable(Gem::Version)) }
|
287
366
|
def current_version
|
288
|
-
@current_version ||=
|
367
|
+
@current_version ||=
|
368
|
+
T.let(
|
369
|
+
dependency.numeric_version,
|
370
|
+
T.nilable(Dependabot::Version)
|
371
|
+
)
|
289
372
|
end
|
290
373
|
|
374
|
+
sig { returns(T::Boolean) }
|
291
375
|
def can_compare_requirements?
|
292
|
-
version_from_requirements &&
|
376
|
+
(version_from_requirements &&
|
293
377
|
latest_version &&
|
294
|
-
version_class.correct?(latest_version.to_s)
|
378
|
+
version_class.correct?(latest_version.to_s)) || false
|
295
379
|
end
|
296
380
|
|
381
|
+
sig { returns(T::Array[T::Hash[Symbol, T.untyped]]) }
|
297
382
|
def changed_requirements
|
298
383
|
(updated_requirements - dependency.requirements)
|
299
384
|
end
|
300
385
|
|
386
|
+
sig { returns(T.nilable(T.any(String, Gem::Version))) }
|
301
387
|
def version_from_requirements
|
302
388
|
@version_from_requirements ||=
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
389
|
+
T.let(
|
390
|
+
dependency.requirements.filter_map { |r| r.fetch(:requirement) }
|
391
|
+
.flat_map { |req_str| requirement_class.requirements_array(req_str) }
|
392
|
+
.flat_map(&:requirements)
|
393
|
+
.reject { |req_array| req_array.first.start_with?("<") }
|
394
|
+
.map(&:last)
|
395
|
+
.max,
|
396
|
+
T.nilable(T.any(String, Gem::Version))
|
397
|
+
)
|
309
398
|
end
|
310
399
|
|
400
|
+
sig { returns(T::Boolean) }
|
311
401
|
def requirements_can_update?
|
312
402
|
return false if changed_requirements.none?
|
313
403
|
|
data/lib/dependabot.rb
CHANGED
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.
|
4
|
+
version: 0.246.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-
|
11
|
+
date: 2024-03-01 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.
|
570
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.246.0
|
571
571
|
post_install_message:
|
572
572
|
rdoc_options: []
|
573
573
|
require_paths:
|