dependabot-github_actions 0.391.0 → 0.392.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8704994a565cd7f061c709f5a5ffae85264f537835a88fe992cee829dd56bae4
4
- data.tar.gz: 6d7d0b3320cf3d64137ab662f3806aa415a2d05e2f5c16c36d09db1bc0b90545
3
+ metadata.gz: 6a530d98ee5deaf59ae4a5fae27332419200128915c4586da2be88280572b200
4
+ data.tar.gz: 1a0809f4f2a0c74c16ffe96834d05f89a27ade9e2da665e7548f52b5d842d044
5
5
  SHA512:
6
- metadata.gz: e17b3f0d4c5a8b4715f91741cfa199ff1112ba092e64542f6d7aed56ebae3fe5d04c5cfc4f2752a9fe0febaca5192518288c3a18535122129aaa9c118de5e543
7
- data.tar.gz: d0f90146d2d2f4e2c512892c834afefdf81a02da7e4d21b477a130264eead6a8f28e3d27f5f3cb2f20d97a36c031a37f0c153d93b4c245abc4674069b29530ce
6
+ metadata.gz: 1aced24aa66cc77c90d02bd74cf45daa7f06b471e1dd9c711ad1895a35d0ddc717d8448e37287b9306bbd0f6c0b6db761dfc88b930452b931311907a0537d641
7
+ data.tar.gz: 1d05ded519f6eedcef7d9dee3192b0fca26d47f8b9c0c83f5fe0848489741ff55be0c806f603f56e05a27e62fa54f0d38a3367685d12b4dad98a381fcc1be81a
@@ -1,4 +1,4 @@
1
- # typed: strict
1
+ # typed: strong
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "sorbet-runtime"
@@ -144,21 +144,21 @@ module Dependabot
144
144
  updated_requirement_pairs =
145
145
  dependency.requirements.zip(T.must(dependency.previous_requirements))
146
146
  .reject do |new_req, old_req|
147
- next true if new_req[:file] != file.name
147
+ next true if new_req.file != file.name
148
148
 
149
- new_req[:source] == T.must(old_req)[:source]
149
+ new_req.source == T.must(old_req).source
150
150
  end
151
151
 
152
152
  updated_content = T.must(file.content)
153
153
 
154
154
  updated_requirement_pairs.each do |new_req, old_req|
155
155
  # TODO: Support updating Docker sources
156
- next unless new_req.fetch(:source).fetch(:type) == "git"
156
+ next unless new_req.source_string("type") == "git"
157
157
 
158
- old_ref = T.must(old_req).fetch(:source).fetch(:ref)
159
- new_ref = new_req.fetch(:source).fetch(:ref)
158
+ old_ref = T.must(T.must(old_req).source_string("ref"))
159
+ new_ref = T.must(new_req.source_string("ref"))
160
160
 
161
- old_declaration = T.must(old_req).fetch(:metadata).fetch(:declaration_string)
161
+ old_declaration = T.must(T.must(old_req).metadata_string("declaration_string"))
162
162
  new_declaration =
163
163
  old_declaration
164
164
  .gsub(/@.*+/, "@#{new_ref}")
@@ -15,14 +15,9 @@ module Dependabot
15
15
 
16
16
  sig { override.returns(T.nilable(Dependabot::Source)) }
17
17
  def look_up_source
18
- info = dependency.requirements.filter_map { |r| r[:source] }.first
19
-
20
- url =
21
- if info.nil?
22
- "https://#{source_hostname}/#{dependency.name}"
23
- else
24
- info[:url] || info.fetch("url")
25
- end
18
+ requirement = dependency.requirements.find(&:source_hash)
19
+ url = requirement&.source_string("url") ||
20
+ "https://#{source_hostname}/#{dependency.name}"
26
21
  Source.from_url(url)
27
22
  end
28
23
 
@@ -65,24 +65,14 @@ module Dependabot
65
65
  sig { override.returns(T::Array[Dependabot::DependencyRequirement]) }
66
66
  def updated_requirements
67
67
  updated_reqs = dependency.requirements.map do |req|
68
- source = T.cast(req.source, GitSource)
68
+ source = req.source_hash
69
69
  updated = updated_ref(source, onboarded: onboarded_requirement?(req))
70
70
  next req unless updated
71
71
 
72
- current = source[:ref]
73
-
74
- # Maintain a short git hash only if it matches the latest
75
- if req[:type] == "git" &&
76
- git_commit_checker.ref_looks_like_commit_sha?(updated) &&
77
- git_commit_checker.ref_looks_like_commit_sha?(T.must(current)) &&
78
- updated.start_with?(T.must(current))
79
- next req
80
- end
81
-
82
- new_source = source.merge(ref: updated)
83
- req.merge(source: new_source)
72
+ new_source = source_with_ref(T.must(source), updated)
73
+ Dependabot::DependencyRequirement.create(req.merge(source: new_source))
84
74
  end
85
- wrap_requirements(updated_reqs)
75
+ updated_reqs
86
76
  end
87
77
 
88
78
  private
@@ -171,9 +161,7 @@ module Dependabot
171
161
  @git_metadata_fetcher ||= T.let(
172
162
  Dependabot::GitMetadataFetcher.new(
173
163
  url: T.must(
174
- dependency.requirements.filter_map do |requirement|
175
- T.cast(requirement.source, T.nilable(GitSource))&.fetch(:url, nil)
176
- end.first
164
+ dependency.requirements.filter_map { |requirement| requirement.source_string("url") }.first
177
165
  ),
178
166
  credentials: credentials
179
167
  ),
@@ -248,20 +236,24 @@ module Dependabot
248
236
  end
249
237
 
250
238
  sig do
251
- params(source: T.nilable(GitSource), onboarded: T::Boolean)
239
+ params(
240
+ source: T.nilable(Dependabot::DependencyRequirement::ObjectHash),
241
+ onboarded: T::Boolean
242
+ )
252
243
  .returns(T.nilable(String))
253
244
  end
254
245
  def updated_ref(source, onboarded: false)
255
246
  # TODO: Support Docker sources
256
247
  return unless git_commit_checker.git_dependency?
257
248
 
258
- finder = onboarded ? latest_version_finder_for(source) : T.must(latest_version_finder)
249
+ git_source = source && symbolize_source(source)
250
+ finder = onboarded ? latest_version_finder_for(git_source) : T.must(latest_version_finder)
259
251
 
260
252
  if vulnerable? && (new_tag = finder.lowest_security_fix_release)
261
253
  return new_tag.fetch(:tag)
262
254
  end
263
255
 
264
- source_git_commit_checker = git_helper.git_commit_checker_for(source)
256
+ source_git_commit_checker = git_helper.git_commit_checker_for(git_source)
265
257
 
266
258
  # Return the git tag if updating a pinned version
267
259
  if source_git_commit_checker.pinned_ref_looks_like_version? &&
@@ -279,6 +271,35 @@ module Dependabot
279
271
  nil
280
272
  end
281
273
 
274
+ sig do
275
+ params(source: Dependabot::DependencyRequirement::ObjectHash)
276
+ .returns(GitSource)
277
+ end
278
+ def symbolize_source(source)
279
+ T.cast(source.to_h { |key, value| [key.to_sym, value] }, GitSource)
280
+ end
281
+
282
+ sig do
283
+ params(
284
+ source: Dependabot::DependencyRequirement::ObjectHash,
285
+ ref: String
286
+ ).returns(Dependabot::DependencyRequirement::ObjectHash)
287
+ end
288
+ def source_with_ref(source, ref)
289
+ updated = source.dup
290
+ key = if source.key?(:ref)
291
+ :ref
292
+ elsif source.key?("ref")
293
+ "ref"
294
+ elsif source.keys.any?(Symbol)
295
+ :ref
296
+ else
297
+ "ref"
298
+ end
299
+ updated[key] = ref
300
+ updated
301
+ end
302
+
282
303
  sig do
283
304
  params(source_checker: Dependabot::GitCommitChecker, finder: LatestVersionFinder)
284
305
  .returns(T.nilable(String))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-github_actions
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.391.0
4
+ version: 0.392.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -15,14 +15,14 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.391.0
18
+ version: 0.392.0
19
19
  type: :runtime
20
20
  prerelease: false
21
21
  version_requirements: !ruby/object:Gem::Requirement
22
22
  requirements:
23
23
  - - '='
24
24
  - !ruby/object:Gem::Version
25
- version: 0.391.0
25
+ version: 0.392.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: debug
28
28
  requirement: !ruby/object:Gem::Requirement
@@ -266,7 +266,7 @@ licenses:
266
266
  - MIT
267
267
  metadata:
268
268
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
269
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.391.0
269
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.392.0
270
270
  rdoc_options: []
271
271
  require_paths:
272
272
  - lib