dependabot-gradle 0.381.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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47a95a22f6928d61384fbdcad6a0f380e947cde49bb5e2b441fc30e9f878ea30
4
- data.tar.gz: c2fbefa823a3cac3888e0a3976d0d17ae79a23501f124db73f344c73788ab42e
3
+ metadata.gz: 3a3b9947c1607a8ada6ef1d74f34deb403f2cf76196658ba15b0390976f96c23
4
+ data.tar.gz: f1471d46f94ed018c4ddfa41c90ab67333fc5a562f3db9e1d9b1a7145964c3bf
5
5
  SHA512:
6
- metadata.gz: 92d0bfb78cfaf20469a27f89908bf0e1552d84f04b9a88dfe417529518be7773ed60e44851697885fb92f728d21055d21b95653d754161c8df607e4b516fe0e5
7
- data.tar.gz: b046a8c623cf05a6375db35f3a6bbb983b4fb94ae764cddd925bf0a66a32df5af0546128bae318496dbbd3654027bd571f219e5d77fc08de9077cfd57860ee34
6
+ metadata.gz: 7d3a0d1e02c8fda4cb95d43834bce4d09e7eb591c8b2690e6e7e8ec2d40cb0c2128917fe129ee7d9c3683a4a5e6a5498351540430074b948bad4b9fd6c0a0fc1
7
+ data.tar.gz: d166b1faeacb7545f0c5327d68209fbbc980fce1a94ad9e6233dd227590ad8a0c8f1fae90380259ba60991850ba274cf6b468470bed59eeebe44085841921619
@@ -26,30 +26,34 @@ module Dependabot
26
26
  version = match.fetch("version")
27
27
 
28
28
  requirements = T.let(
29
- [{
30
- requirement: version,
31
- file: properties_file.name,
32
- source: {
33
- type: Distributions::DISTRIBUTION_DEPENDENCY_TYPE,
34
- url: distribution_url,
35
- property: "distributionUrl"
36
- },
37
- groups: []
38
- }],
39
- T::Array[T::Hash[Symbol, T.untyped]]
29
+ [DependencyRequirement.create(
30
+ {
31
+ requirement: version,
32
+ file: properties_file.name,
33
+ source: {
34
+ type: Distributions::DISTRIBUTION_DEPENDENCY_TYPE,
35
+ url: distribution_url,
36
+ property: "distributionUrl"
37
+ },
38
+ groups: []
39
+ }
40
+ )],
41
+ T::Array[Dependabot::DependencyRequirement]
40
42
  )
41
43
 
42
44
  if checksum
43
- requirements << {
44
- requirement: checksum,
45
- file: properties_file.name,
46
- source: {
47
- type: Distributions::DISTRIBUTION_DEPENDENCY_TYPE,
48
- url: "#{distribution_url}.sha256",
49
- property: "distributionSha256Sum"
50
- },
51
- groups: []
52
- }
45
+ requirements << DependencyRequirement.create(
46
+ {
47
+ requirement: checksum,
48
+ file: properties_file.name,
49
+ source: {
50
+ type: Distributions::DISTRIBUTION_DEPENDENCY_TYPE,
51
+ url: "#{distribution_url}.sha256",
52
+ property: "distributionSha256Sum"
53
+ },
54
+ groups: []
55
+ }
56
+ )
53
57
  end
54
58
 
55
59
  Dependency.new(
@@ -2,7 +2,9 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  require "sorbet-runtime"
5
+ require "base64"
5
6
  require "shellwords"
7
+ require "pathname"
6
8
 
7
9
  require "dependabot/gradle/distributions"
8
10
 
@@ -39,15 +41,12 @@ module Dependabot
39
41
 
40
42
  # rubocop:disable Metrics/AbcSize
41
43
  # rubocop:disable Metrics/MethodLength
42
- # rubocop:disable Metrics/PerceivedComplexity
43
44
  sig { params(build_file: Dependabot::DependencyFile).returns(T::Array[Dependabot::DependencyFile]) }
44
45
  def update_files(build_file)
45
46
  # We only run this updater if it's a distribution dependency
46
47
  return [] unless Distributions.distribution_requirements?(dependency.requirements)
47
48
 
48
- local_files = dependency_files.select do |file|
49
- file.directory == build_file.directory && target_file?(file)
50
- end
49
+ local_files = local_wrapper_files(build_file)
51
50
 
52
51
  # If we don't have any files in the build files don't generate one
53
52
  return [] unless local_files.any?
@@ -107,7 +106,6 @@ module Dependabot
107
106
  end
108
107
  # rubocop:enable Metrics/AbcSize
109
108
  # rubocop:enable Metrics/MethodLength
110
- # rubocop:enable Metrics/PerceivedComplexity
111
109
 
112
110
  private
113
111
 
@@ -116,8 +114,48 @@ module Dependabot
116
114
  @target_files.any? { |r| "/#{file.name}".end_with?(r) }
117
115
  end
118
116
 
117
+ sig { params(build_file: Dependabot::DependencyFile).returns(T::Array[Dependabot::DependencyFile]) }
118
+ def local_wrapper_files(build_file)
119
+ wrapper_root = wrapper_root_for(build_file)
120
+
121
+ dependency_files.select do |file|
122
+ file.directory == build_file.directory && target_file_for_wrapper_root?(file, wrapper_root)
123
+ end
124
+ end
125
+
126
+ sig { params(file: Dependabot::DependencyFile, wrapper_root: String).returns(T::Boolean) }
127
+ def target_file_for_wrapper_root?(file, wrapper_root)
128
+ @target_files.any? do |target_file|
129
+ target_path = target_file.delete_prefix("/")
130
+ expected_path = wrapper_root.empty? ? target_path : File.join(wrapper_root, target_path)
131
+ file_path(file) == Pathname.new(expected_path).cleanpath.to_path
132
+ end
133
+ end
134
+
135
+ sig { params(build_file: Dependabot::DependencyFile).returns(String) }
136
+ def wrapper_root_for(build_file)
137
+ path = file_path(build_file)
138
+ root = if target_file?(build_file)
139
+ File.dirname(path, 3)
140
+ else
141
+ File.dirname(path)
142
+ end
143
+
144
+ root == "." ? "" : root
145
+ end
146
+
147
+ sig { params(file: Dependabot::DependencyFile).returns(String) }
148
+ def file_path(file)
149
+ Pathname.new(file.name).cleanpath.to_path
150
+ end
151
+
119
152
  # rubocop:disable Metrics/PerceivedComplexity
120
- sig { params(requirements: T::Array[T::Hash[Symbol, T.untyped]], network_timeout: T.nilable(String)).returns(T::Array[String]) }
153
+ sig do
154
+ params(
155
+ requirements: T::Array[Dependabot::DependencyRequirement],
156
+ network_timeout: T.nilable(String)
157
+ ).returns(T::Array[String])
158
+ end
121
159
  def command_args(requirements, network_timeout)
122
160
  version = T.let(requirements[0]&.[](:requirement), String)
123
161
  checksum = T.let(requirements[1]&.[](:requirement), T.nilable(String)) if requirements.size > 1
@@ -191,7 +229,11 @@ module Dependabot
191
229
  end
192
230
  def update_files_content(temp_dir, local_files, updated_files)
193
231
  local_files.each do |file|
194
- f_content = File.read(File.join(temp_dir, file.directory, file.name))
232
+ f_content = if file.binary?
233
+ File.binread(File.join(temp_dir, file.directory, file.name))
234
+ else
235
+ File.read(File.join(temp_dir, file.directory, file.name))
236
+ end
195
237
  tmp_file = file.dup
196
238
  tmp_file.content = tmp_file.binary? ? Base64.encode64(f_content) : f_content
197
239
  updated_files[T.must(updated_files.index(file))] = tmp_file
@@ -203,7 +245,7 @@ module Dependabot
203
245
  files_to_populate.each do |file|
204
246
  in_path_name = File.join(temp_dir, file.directory, file.name)
205
247
  FileUtils.mkdir_p(File.dirname(in_path_name))
206
- File.write(in_path_name, file.content)
248
+ File.binwrite(in_path_name, file.decoded_content)
207
249
  end
208
250
  end
209
251
 
@@ -62,18 +62,20 @@ module Dependabot
62
62
  nil
63
63
  end
64
64
 
65
- sig { override.returns(T::Array[T::Hash[Symbol, T.untyped]]) }
65
+ sig { override.returns(T::Array[Dependabot::DependencyRequirement]) }
66
66
  def updated_requirements
67
67
  property_names =
68
68
  declarations_using_a_property
69
69
  .map { |req| req.dig(:metadata, :property_name) }
70
70
 
71
- RequirementsUpdater.new(
72
- requirements: dependency.requirements,
73
- latest_version: preferred_resolvable_version&.to_s,
74
- source_url: preferred_version_details&.fetch(:source_url),
75
- properties_to_update: property_names
76
- ).updated_requirements
71
+ wrap_requirements(
72
+ RequirementsUpdater.new(
73
+ requirements: dependency.requirements,
74
+ latest_version: preferred_resolvable_version&.to_s,
75
+ source_url: preferred_version_details&.fetch(:source_url),
76
+ properties_to_update: property_names
77
+ ).updated_requirements
78
+ )
77
79
  end
78
80
 
79
81
  sig { override.returns(T::Boolean) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dependabot-gradle
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.381.0
4
+ version: 0.382.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dependabot
@@ -15,28 +15,28 @@ dependencies:
15
15
  requirements:
16
16
  - - '='
17
17
  - !ruby/object:Gem::Version
18
- version: 0.381.0
18
+ version: 0.382.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.381.0
25
+ version: 0.382.0
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: dependabot-maven
28
28
  requirement: !ruby/object:Gem::Requirement
29
29
  requirements:
30
30
  - - '='
31
31
  - !ruby/object:Gem::Version
32
- version: 0.381.0
32
+ version: 0.382.0
33
33
  type: :runtime
34
34
  prerelease: false
35
35
  version_requirements: !ruby/object:Gem::Requirement
36
36
  requirements:
37
37
  - - '='
38
38
  - !ruby/object:Gem::Version
39
- version: 0.381.0
39
+ version: 0.382.0
40
40
  - !ruby/object:Gem::Dependency
41
41
  name: debug
42
42
  requirement: !ruby/object:Gem::Requirement
@@ -286,7 +286,7 @@ licenses:
286
286
  - MIT
287
287
  metadata:
288
288
  bug_tracker_uri: https://github.com/dependabot/dependabot-core/issues
289
- changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.381.0
289
+ changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.382.0
290
290
  rdoc_options: []
291
291
  require_paths:
292
292
  - lib