dependabot-common 0.380.0 → 0.382.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.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/lib/dependabot/clients/github_with_retries.rb +2 -2
  3. data/lib/dependabot/clients/gitlab_with_retries.rb +2 -2
  4. data/lib/dependabot/command_helpers.rb +1 -1
  5. data/lib/dependabot/config/ignore_condition.rb +1 -1
  6. data/lib/dependabot/credential.rb +14 -1
  7. data/lib/dependabot/dependency.rb +12 -10
  8. data/lib/dependabot/dependency_file.rb +1 -1
  9. data/lib/dependabot/dependency_requirement.rb +94 -0
  10. data/lib/dependabot/errors.rb +12 -0
  11. data/lib/dependabot/file_fetchers/base.rb +34 -32
  12. data/lib/dependabot/file_parsers/base/dependency_set.rb +1 -1
  13. data/lib/dependabot/file_parsers/base.rb +5 -0
  14. data/lib/dependabot/file_updaters/artifact_updater.rb +40 -4
  15. data/lib/dependabot/file_updaters/vendor_updater.rb +42 -3
  16. data/lib/dependabot/git_commit_checker.rb +18 -17
  17. data/lib/dependabot/git_tag_details.rb +78 -0
  18. data/lib/dependabot/metadata_finders/base/changelog_finder.rb +11 -14
  19. data/lib/dependabot/metadata_finders/base/commits_finder.rb +13 -9
  20. data/lib/dependabot/metadata_finders/base/release_finder.rb +14 -12
  21. data/lib/dependabot/notices.rb +1 -1
  22. data/lib/dependabot/package/package_latest_version_finder.rb +8 -3
  23. data/lib/dependabot/pull_request_creator/branch_namer/solo_strategy.rb +16 -16
  24. data/lib/dependabot/pull_request_creator/github.rb +17 -17
  25. data/lib/dependabot/pull_request_creator/gitlab.rb +16 -14
  26. data/lib/dependabot/pull_request_creator/labeler.rb +19 -17
  27. data/lib/dependabot/pull_request_creator/pr_name_prefixer.rb +3 -3
  28. data/lib/dependabot/pull_request_updater/github.rb +13 -11
  29. data/lib/dependabot/pull_request_updater/gitlab.rb +2 -2
  30. data/lib/dependabot/shared_helpers.rb +2 -1
  31. data/lib/dependabot/update_checkers/base.rb +15 -1
  32. data/lib/dependabot.rb +1 -1
  33. metadata +4 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3a6875517541de554dabb2e9256474b7b063b2af8a82bbf6579eb86e729e917e
4
- data.tar.gz: c29581ace26310f39fb0b24c44702c943c01ab49bcc7787d9dfe4e5dd6093a5c
3
+ metadata.gz: 6b53185ee3c744622d14656ac582aaa779b5b9f3394497824d49561fe78fe2d8
4
+ data.tar.gz: cd5ce58e980459603217ea2693475a224691f67149215d1fb5031472bc065507
5
5
  SHA512:
6
- metadata.gz: 8f33816f8f94a02f956f067923cd79f44783dec54c23745a713cfc3fc51f6e27b55294ba31fa6f3640626988ad4a8d89f4a68b7971fe5ea14ff6886828b4d718
7
- data.tar.gz: 7a24d2dd23e16b58f8eadc9b975146983c8693e99d0a473401ca392438bc5c81ed7e2b2c1a79e070c6e40189b955783000bac75b59811583a3d4a6fde8ce43b8
6
+ metadata.gz: 1216f4ef150d1c76b7180f780b1d67831359c9f327bf1a00cf885d3f9b3313ce354a694803de8ec91c1eebc138e922d65cde4f4e5ede88f6da7ceb23c6306026
7
+ data.tar.gz: 1377f5537d8d8e637945e35d59ba58dde50ec048f29abf6e9d50c4239ce2a7ca292aa379cfd7c28af7c9efe12723bdf71d55a007ad7e4839a177472f57f7a256
@@ -88,7 +88,7 @@ module Dependabot
88
88
 
89
89
  sig { params(repo: String, branch: String).returns(String) }
90
90
  def fetch_commit(repo, branch)
91
- response = T.unsafe(self).ref(repo, "heads/#{branch}")
91
+ response = T.unsafe(ref(repo, "heads/#{branch}"))
92
92
 
93
93
  raise Octokit::NotFound if response.is_a?(Array)
94
94
 
@@ -97,7 +97,7 @@ module Dependabot
97
97
 
98
98
  sig { params(repo: String).returns(String) }
99
99
  def fetch_default_branch(repo)
100
- T.unsafe(self).repository(repo).default_branch
100
+ T.unsafe(repository(repo)).default_branch
101
101
  end
102
102
 
103
103
  ############
@@ -67,12 +67,12 @@ module Dependabot
67
67
 
68
68
  sig { params(repo: String, branch: String).returns(String) }
69
69
  def fetch_commit(repo, branch)
70
- T.unsafe(self).branch(repo, branch).commit.id
70
+ T.unsafe(branch(repo, branch)).commit.id
71
71
  end
72
72
 
73
73
  sig { params(repo: String).returns(String) }
74
74
  def fetch_default_branch(repo)
75
- T.unsafe(self).project(repo).default_branch
75
+ T.unsafe(project(repo)).default_branch
76
76
  end
77
77
 
78
78
  ############
@@ -96,7 +96,7 @@ module Dependabot
96
96
  stdout = T.let("", String)
97
97
  stderr = T.let("", String)
98
98
  status = T.let(nil, T.nilable(ProcessStatus))
99
- pid = T.let(nil, T.untyped)
99
+ pid = T.let(nil, T.nilable(Integer))
100
100
  start_time = Time.now
101
101
 
102
102
  begin
@@ -52,7 +52,7 @@ module Dependabot
52
52
  update_types.map(&:downcase).filter_map(&:strip)
53
53
  end
54
54
 
55
- sig { params(dependency: Dependency).returns(T::Array[T.untyped]) }
55
+ sig { params(dependency: Dependency).returns(T::Array[String]) }
56
56
  def versions_by_type(dependency)
57
57
  version = correct_version_for(dependency)
58
58
  return [] unless version
@@ -11,10 +11,20 @@ module Dependabot
11
11
 
12
12
  def_delegators :@credential, :fetch, :keys, :[]=, :delete, :slice, :values, :entries
13
13
 
14
- sig { params(credential: T::Hash[String, T.any(T::Boolean, String)]).void }
14
+ sig { params(credential: T::Hash[String, T.any(T::Boolean, String, T::Array[String])]).void }
15
15
  def initialize(credential)
16
16
  @replaces_base = T.let(credential["replaces-base"] == true, T::Boolean)
17
17
  credential.delete("replaces-base")
18
+
19
+ raw_scope = credential.delete("scope")
20
+ @scope = T.let(
21
+ case raw_scope
22
+ when String then [raw_scope]
23
+ when Array then raw_scope
24
+ end,
25
+ T.nilable(T::Array[String])
26
+ )
27
+
18
28
  @credential = T.let(T.unsafe(credential), T::Hash[String, String])
19
29
  end
20
30
 
@@ -23,6 +33,9 @@ module Dependabot
23
33
  @replaces_base
24
34
  end
25
35
 
36
+ sig { returns(T.nilable(T::Array[String])) }
37
+ attr_reader :scope
38
+
26
39
  sig { params(key: String).returns(T.nilable(String)) }
27
40
  def [](key)
28
41
  @credential[key]
@@ -2,6 +2,7 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "sorbet-runtime"
5
+ require "dependabot/dependency_requirement"
5
6
  require "dependabot/version"
6
7
 
7
8
  module Dependabot
@@ -90,7 +91,7 @@ module Dependabot
90
91
  sig { returns(T.nilable(String)) }
91
92
  attr_reader :version
92
93
 
93
- sig { returns(T::Array[T::Hash[Symbol, T.untyped]]) }
94
+ sig { returns(T::Array[Dependabot::DependencyRequirement]) }
94
95
  attr_reader :requirements
95
96
 
96
97
  sig { returns(String) }
@@ -99,7 +100,7 @@ module Dependabot
99
100
  sig { returns(T.nilable(String)) }
100
101
  attr_reader :previous_version
101
102
 
102
- sig { returns(T.nilable(T::Array[T::Hash[Symbol, T.untyped]])) }
103
+ sig { returns(T.nilable(T::Array[Dependabot::DependencyRequirement])) }
103
104
  attr_reader :previous_requirements
104
105
 
105
106
  sig { returns(T.nilable(String)) }
@@ -124,7 +125,6 @@ module Dependabot
124
125
  sig { returns(T.nilable(Time)) }
125
126
  attr_accessor :attribution_timestamp
126
127
 
127
- # rubocop:disable Metrics/AbcSize
128
128
  # rubocop:disable Metrics/PerceivedComplexity
129
129
  sig do
130
130
  params(
@@ -162,12 +162,15 @@ module Dependabot
162
162
  T.nilable(String)
163
163
  )
164
164
  @version = nil if @version == ""
165
- @requirements = T.let(requirements.map { |req| symbolize_keys(req) }, T::Array[T::Hash[Symbol, T.untyped]])
165
+ @requirements = T.let(
166
+ requirements.map { |req| DependencyRequirement.create(req) },
167
+ T::Array[Dependabot::DependencyRequirement]
168
+ )
166
169
  @previous_version = previous_version
167
170
  @previous_version = nil if @previous_version == ""
168
171
  @previous_requirements = T.let(
169
- previous_requirements&.map { |req| symbolize_keys(req) },
170
- T.nilable(T::Array[T::Hash[Symbol, T.untyped]])
172
+ previous_requirements&.map { |req| DependencyRequirement.create(req) },
173
+ T.nilable(T::Array[Dependabot::DependencyRequirement])
171
174
  )
172
175
  @package_manager = package_manager
173
176
  @directory = directory
@@ -181,7 +184,6 @@ module Dependabot
181
184
  @metadata = T.let(symbolize_keys(metadata || {}), T::Hash[Symbol, T.untyped])
182
185
  check_values
183
186
  end
184
- # rubocop:enable Metrics/AbcSize
185
187
  # rubocop:enable Metrics/PerceivedComplexity
186
188
 
187
189
  sig { returns(T::Boolean) }
@@ -272,7 +274,7 @@ module Dependabot
272
274
  end
273
275
  end
274
276
 
275
- sig { params(requirements: T::Array[T::Hash[Symbol, T.untyped]]).returns(T.nilable(String)) }
277
+ sig { params(requirements: T::Array[Dependabot::DependencyRequirement]).returns(T.nilable(String)) }
276
278
  def docker_digest_from_reqs(requirements)
277
279
  requirements
278
280
  .filter_map { |r| r.dig(:source, "digest") || r.dig(:source, :digest) }
@@ -340,9 +342,9 @@ module Dependabot
340
342
  self == other
341
343
  end
342
344
 
343
- sig { returns(T::Array[T::Hash[Symbol, T.untyped]]) }
345
+ sig { returns(T::Array[Dependabot::DependencyRequirement]) }
344
346
  def specific_requirements
345
- requirements.select { |r| requirement_class.new(r[:requirement]).specific? }
347
+ requirements.select { |r| requirement_class.new(r.requirement).specific? }
346
348
  end
347
349
 
348
350
  sig { returns(T.class_of(Dependabot::Requirement)) }
@@ -123,7 +123,7 @@ module Dependabot
123
123
  raise "Only symlinked files must specify a target!" if symlink_target
124
124
  end
125
125
 
126
- sig { returns(T::Hash[String, T.untyped]) }
126
+ sig { returns(T::Hash[String, T.nilable(T.any(String, T::Boolean))]) }
127
127
  def to_h
128
128
  details = {
129
129
  "name" => name,
@@ -0,0 +1,94 @@
1
+ # typed: strict
2
+ # frozen_string_literal: true
3
+
4
+ require "sorbet-runtime"
5
+
6
+ module Dependabot
7
+ # A single requirement entry within Dependency#requirements, e.g.:
8
+ #
9
+ # {
10
+ # requirement: ">= 1.0, < 2.0",
11
+ # file: "Gemfile",
12
+ # groups: [:default],
13
+ # source: { type: "rubygems", url: "https://rubygems.org" },
14
+ # metadata: { property_name: "rails.version" } # optional
15
+ # }
16
+ #
17
+ # Subclasses Hash so it is a drop-in replacement at call sites (and in
18
+ # type annotations) that treat requirement entries as
19
+ # T::Hash[Symbol, T.untyped], while exposing typed readers for the
20
+ # well-known keys. New code should prefer the typed readers; hash-style
21
+ # access remains supported while call sites are migrated gradually.
22
+ #
23
+ # Wire compatibility: instances serialise to JSON exactly like the plain
24
+ # hash they were created from, and compare equal (==/eql?/#hash) to plain
25
+ # hashes with the same content, so existing comparisons, Array/Set
26
+ # operations, and API payloads are unaffected.
27
+ #
28
+ # Note on Hash methods: in Ruby 3+, #merge, #dup and #compact preserve
29
+ # this class, while #select, #reject, #except, #transform_values and
30
+ # #to_h return plain Hash instances. Dependency#initialize re-wraps
31
+ # whatever it is given, so both styles remain safe.
32
+ class DependencyRequirement < Hash
33
+ extend T::Sig
34
+ extend T::Generic
35
+
36
+ # The values of a requirement entry are heterogeneous and
37
+ # ecosystem-specific, so this bridge class is necessarily untyped at
38
+ # the Hash level; the typed readers below are the migration path.
39
+ # rubocop:disable Sorbet/ForbidTUntyped
40
+ K = type_member { { fixed: Symbol } }
41
+ V = type_member { { fixed: T.untyped } }
42
+ Elem = type_member { { fixed: [Symbol, T.untyped] } }
43
+
44
+ # Builds a DependencyRequirement from a requirement hash, symbolising
45
+ # top-level keys. Accepts both plain hashes and existing
46
+ # DependencyRequirement instances and always returns a new instance.
47
+ sig { params(hash: T::Hash[T.any(Symbol, String), T.untyped]).returns(DependencyRequirement) }
48
+ def self.create(hash)
49
+ requirement = new
50
+ requirement.replace(hash.keys.to_h { |k| [k.to_sym, hash[k]] })
51
+ requirement
52
+ end
53
+
54
+ # The version constraint string, e.g. ">= 1.0, < 2.0". Nil when the
55
+ # dependency is pinned by a lockfile rather than a manifest constraint.
56
+ sig { returns(T.nilable(String)) }
57
+ def requirement
58
+ self[:requirement]
59
+ end
60
+
61
+ # The manifest file this requirement was declared in, e.g. "Gemfile".
62
+ sig { returns(T.nilable(String)) }
63
+ def file
64
+ self[:file]
65
+ end
66
+
67
+ # The dependency groups this requirement belongs to, e.g. ["dev"] or
68
+ # [:default]. Element types vary by ecosystem (strings or symbols).
69
+ # Nilable because some requirement entries are constructed with
70
+ # groups: nil, and the reader must reflect that to stay a drop-in for
71
+ # the underlying hash access under sorbet-runtime.
72
+ sig { returns(T.nilable(T::Array[T.untyped])) }
73
+ def groups
74
+ self[:groups]
75
+ end
76
+
77
+ # The source details for the dependency, e.g.
78
+ # { type: "git", url: "https://github.com/..." }. Keys may be symbols
79
+ # or strings depending on whether the requirement was built by a file
80
+ # parser or deserialised from a job definition.
81
+ sig { returns(T.nilable(T::Hash[T.any(Symbol, String), T.untyped])) }
82
+ def source
83
+ self[:source]
84
+ end
85
+
86
+ # Optional ecosystem-specific metadata about the requirement, e.g.
87
+ # { property_name: "rails.version" }.
88
+ sig { returns(T.nilable(T::Hash[T.any(Symbol, String), T.untyped])) }
89
+ def metadata
90
+ self[:metadata]
91
+ end
92
+ # rubocop:enable Sorbet/ForbidTUntyped
93
+ end
94
+ end
@@ -393,6 +393,18 @@ module Dependabot
393
393
  # rubocop:enable Lint/RedundantCopDisableDirective
394
394
  # rubocop:enable Metrics/AbcSize
395
395
 
396
+ # Interface for error classes that provide Sentry context (e.g. fingerprint).
397
+ # Include this module in any error class that defines #sentry_context.
398
+ module HasSentryContext
399
+ extend T::Sig
400
+ extend T::Helpers
401
+
402
+ interface!
403
+
404
+ sig { abstract.returns(T::Hash[Symbol, T.untyped]) }
405
+ def sentry_context; end
406
+ end
407
+
396
408
  class DependabotError < StandardError
397
409
  extend T::Sig
398
410
 
@@ -393,19 +393,19 @@ module Dependabot
393
393
  .returns(T.nilable(T::Hash[String, T.untyped]))
394
394
  end
395
395
  def update_linked_paths(repo, path, commit, github_response)
396
- case T.unsafe(github_response).type
396
+ case github_response[:type]
397
397
  when "submodule"
398
- sub_source = Source.from_url(T.unsafe(github_response).submodule_git_url)
398
+ sub_source = Source.from_url(github_response[:submodule_git_url])
399
399
  return unless sub_source
400
400
 
401
401
  @linked_paths[path] = {
402
402
  repo: sub_source.repo,
403
403
  provider: sub_source.provider,
404
- commit: T.unsafe(github_response).sha,
404
+ commit: github_response[:sha],
405
405
  path: "/"
406
406
  }
407
407
  when "symlink"
408
- updated_path = File.join(File.dirname(path), T.unsafe(github_response).target)
408
+ updated_path = File.join(File.dirname(path), github_response[:target])
409
409
  @linked_paths[path] = {
410
410
  repo: repo,
411
411
  provider: "github",
@@ -564,10 +564,10 @@ module Dependabot
564
564
  sig { params(repo: String, path: String, commit: String).returns(T::Array[RepositoryContent]) }
565
565
  def _github_repo_contents(repo, path, commit)
566
566
  path = path.gsub(" ", "%20")
567
- github_response = T.unsafe(github_client).contents(repo, path: path, ref: commit)
567
+ github_response = github_client.contents(repo, path: path, ref: commit)
568
568
 
569
569
  if github_response.respond_to?(:type)
570
- update_linked_paths(repo, path, commit, github_response)
570
+ update_linked_paths(repo, path, commit, T.unsafe(github_response))
571
571
  raise Octokit::NotFound
572
572
  end
573
573
 
@@ -629,18 +629,20 @@ module Dependabot
629
629
  sig { params(file: Sawyer::Resource).returns(RepositoryContent) }
630
630
  def _build_github_file_struct(file)
631
631
  RepositoryContent.new(
632
- name: T.unsafe(file).name,
633
- path: T.unsafe(file).path,
634
- type: T.unsafe(file).type,
635
- sha: T.unsafe(file).sha,
636
- size: T.unsafe(file).size
632
+ name: file[:name],
633
+ path: file[:path],
634
+ type: file[:type],
635
+ sha: file[:sha],
636
+ size: file[:size]
637
637
  )
638
638
  end
639
639
 
640
640
  sig { params(repo: String, path: String, commit: String).returns(T::Array[RepositoryContent]) }
641
641
  def _gitlab_repo_contents(repo, path, commit)
642
- T.unsafe(gitlab_client)
643
- .repo_tree(repo, path: path, ref: commit, per_page: 100)
642
+ T.unsafe(
643
+ gitlab_client
644
+ .repo_tree(repo, path: path, ref: commit, per_page: 100)
645
+ )
644
646
  .map do |file|
645
647
  # GitLab API essentially returns the output from `git ls-tree`
646
648
  type = case file.type
@@ -681,12 +683,12 @@ module Dependabot
681
683
 
682
684
  sig { params(repo: String, path: String, commit: String).returns(T::Array[RepositoryContent]) }
683
685
  def _bitbucket_repo_contents(repo, path, commit)
684
- response = T.unsafe(bitbucket_client)
685
- .fetch_repo_contents(
686
- repo,
687
- commit,
688
- path
689
- )
686
+ response = bitbucket_client
687
+ .fetch_repo_contents(
688
+ repo,
689
+ commit,
690
+ path
691
+ )
690
692
 
691
693
  response.map do |file|
692
694
  type = case file.fetch("type")
@@ -775,12 +777,12 @@ module Dependabot
775
777
  when "github"
776
778
  _fetch_file_content_from_github(path, repo, commit)
777
779
  when "gitlab"
778
- tmp = T.unsafe(gitlab_client).get_file(repo, path, commit).content
780
+ tmp = T.unsafe(gitlab_client.get_file(repo, path, commit)).content
779
781
  decode_binary_string(tmp)
780
782
  when "azure"
781
783
  azure_client.fetch_file_contents(commit, path)
782
784
  when "bitbucket"
783
- T.unsafe(bitbucket_client).fetch_file_contents(repo, commit, path)
785
+ bitbucket_client.fetch_file_contents(repo, commit, path)
784
786
  when "codecommit"
785
787
  codecommit_client.fetch_file_contents(repo, commit, path)
786
788
  else raise "Unsupported provider '#{source.provider}'."
@@ -790,30 +792,30 @@ module Dependabot
790
792
  # rubocop:disable Metrics/AbcSize
791
793
  sig { params(path: String, repo: String, commit: String).returns(String) }
792
794
  def _fetch_file_content_from_github(path, repo, commit)
793
- tmp = T.unsafe(github_client).contents(repo, path: path, ref: commit)
795
+ tmp = github_client.contents(repo, path: path, ref: commit)
794
796
 
795
797
  raise Octokit::NotFound if tmp.is_a?(Array)
796
798
 
797
- if tmp.type == "symlink"
799
+ if T.unsafe(tmp).type == "symlink"
798
800
  @linked_paths[path] = {
799
801
  repo: repo,
800
802
  provider: "github",
801
803
  commit: commit,
802
- path: Pathname.new(tmp.target).cleanpath.to_path
804
+ path: Pathname.new(T.unsafe(tmp).target).cleanpath.to_path
803
805
  }
804
- tmp = T.unsafe(github_client).contents(
806
+ tmp = github_client.contents(
805
807
  repo,
806
- path: Pathname.new(tmp.target).cleanpath.to_path,
808
+ path: Pathname.new(T.unsafe(tmp).target).cleanpath.to_path,
807
809
  ref: commit
808
810
  )
809
811
  end
810
812
 
811
- if tmp.content == ""
813
+ if T.unsafe(tmp).content == ""
812
814
  # The file may have exceeded the 1MB limit
813
815
  # see https://github.blog/changelog/2022-05-03-increased-file-size-limit-when-retrieving-file-contents-via-rest-api/
814
- T.unsafe(github_client).contents(repo, path: path, ref: commit, accept: "application/vnd.github.v3.raw")
816
+ T.unsafe(github_client.contents(repo, path: path, ref: commit, accept: "application/vnd.github.v3.raw"))
815
817
  else
816
- decode_binary_string(tmp.content)
818
+ decode_binary_string(T.unsafe(tmp).content)
817
819
  end
818
820
  rescue Octokit::Forbidden => e
819
821
  raise unless e.message.include?("too_large")
@@ -825,10 +827,10 @@ module Dependabot
825
827
  file_details = repo_contents(dir: dir).find { |f| f.name == basename }
826
828
  raise unless file_details
827
829
 
828
- tmp = T.unsafe(github_client).blob(repo, file_details.sha)
829
- return tmp.content if tmp.encoding == "utf-8"
830
+ tmp = github_client.blob(repo, file_details.sha)
831
+ return T.unsafe(tmp).content if T.unsafe(tmp).encoding == "utf-8"
830
832
 
831
- decode_binary_string(tmp.content)
833
+ decode_binary_string(T.unsafe(tmp).content)
832
834
  end
833
835
  # rubocop:enable Metrics/AbcSize
834
836
 
@@ -33,7 +33,7 @@ module Dependabot
33
33
  @dependencies.values.filter_map(&:combined)
34
34
  end
35
35
 
36
- sig { params(dep: Dependabot::Dependency).returns(T.untyped) }
36
+ sig { params(dep: Dependabot::Dependency).returns(T.self_type) }
37
37
  def <<(dep)
38
38
  T.must(@dependencies[key_for_dependency(dep)]) << dep
39
39
  self
@@ -28,6 +28,11 @@ module Dependabot
28
28
  sig { returns(T::Hash[Symbol, T.untyped]) }
29
29
  attr_reader :options
30
30
 
31
+ sig { returns(T::Boolean) }
32
+ def reject_external_code?
33
+ @reject_external_code
34
+ end
35
+
31
36
  sig do
32
37
  params(
33
38
  dependency_files: T::Array[Dependabot::DependencyFile],
@@ -1,4 +1,4 @@
1
- # typed: strict
1
+ # typed: strong
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "sorbet-runtime"
@@ -120,11 +120,47 @@ module Dependabot
120
120
 
121
121
  sig do
122
122
  overridable
123
- .params(parameters: T::Hash[Symbol, T.untyped])
123
+ .params(
124
+ name: String,
125
+ content: T.nilable(String),
126
+ directory: String,
127
+ type: String,
128
+ support_file: T::Boolean,
129
+ vendored_file: T::Boolean,
130
+ symlink_target: T.nilable(String),
131
+ content_encoding: String,
132
+ deleted: T::Boolean,
133
+ operation: String,
134
+ mode: T.nilable(String)
135
+ )
124
136
  .returns(Dependabot::DependencyFile)
125
137
  end
126
- def create_dependency_file(parameters)
127
- Dependabot::DependencyFile.new(**T.unsafe(parameters))
138
+ def create_dependency_file(
139
+ name:,
140
+ content: nil,
141
+ directory: "/",
142
+ type: "file",
143
+ support_file: false,
144
+ vendored_file: false,
145
+ symlink_target: nil,
146
+ content_encoding: Dependabot::DependencyFile::ContentEncoding::UTF_8,
147
+ deleted: false,
148
+ operation: Dependabot::DependencyFile::Operation::UPDATE,
149
+ mode: nil
150
+ )
151
+ Dependabot::DependencyFile.new(
152
+ name: name,
153
+ content: content,
154
+ directory: directory,
155
+ type: type,
156
+ support_file: support_file,
157
+ vendored_file: vendored_file,
158
+ symlink_target: symlink_target,
159
+ content_encoding: content_encoding,
160
+ deleted: deleted,
161
+ operation: operation,
162
+ mode: mode
163
+ )
128
164
  end
129
165
  end
130
166
  end
@@ -31,13 +31,52 @@ module Dependabot
31
31
 
32
32
  private
33
33
 
34
+ # VendorUpdater always flags files as vendored, so it accepts but ignores
35
+ # the vendored_file argument. The parameter must stay to keep the override
36
+ # signature compatible with ArtifactUpdater#create_dependency_file.
34
37
  sig do
35
38
  override
36
- .params(parameters: T::Hash[Symbol, T.untyped])
39
+ .params(
40
+ name: String,
41
+ content: T.nilable(String),
42
+ directory: String,
43
+ type: String,
44
+ support_file: T::Boolean,
45
+ vendored_file: T::Boolean,
46
+ symlink_target: T.nilable(String),
47
+ content_encoding: String,
48
+ deleted: T::Boolean,
49
+ operation: String,
50
+ mode: T.nilable(String)
51
+ )
37
52
  .returns(Dependabot::DependencyFile)
38
53
  end
39
- def create_dependency_file(parameters)
40
- Dependabot::DependencyFile.new(**T.unsafe({ **parameters, vendored_file: true }))
54
+ def create_dependency_file(
55
+ name:,
56
+ content: nil,
57
+ directory: "/",
58
+ type: "file",
59
+ support_file: false,
60
+ vendored_file: false, # rubocop:disable Lint/UnusedMethodArgument
61
+ symlink_target: nil,
62
+ content_encoding: Dependabot::DependencyFile::ContentEncoding::UTF_8,
63
+ deleted: false,
64
+ operation: Dependabot::DependencyFile::Operation::UPDATE,
65
+ mode: nil
66
+ )
67
+ super(
68
+ name: name,
69
+ content: content,
70
+ directory: directory,
71
+ type: type,
72
+ support_file: support_file,
73
+ vendored_file: true,
74
+ symlink_target: symlink_target,
75
+ content_encoding: content_encoding,
76
+ deleted: deleted,
77
+ operation: operation,
78
+ mode: mode
79
+ )
41
80
  end
42
81
  end
43
82
  end