dependabot-cargo 0.355.0 → 0.356.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 +4 -4
- data/lib/dependabot/cargo/file_fetcher.rb +49 -18
- metadata +4 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9f0d7eb46b51a382f765bccd4505b942d566a2df946494b98f25df68cf38186c
|
|
4
|
+
data.tar.gz: da002ccfe17d219b0b14f92720c43ded25887811661139e5f357a6783fc672fc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: f7eab2d45f0400958efe456503a524efb442c21674da2788af186efb04421a5016af4072899b800ad89bb2f16051889e2e20e6b123914e6e63fcbd010fa83a38
|
|
7
|
+
data.tar.gz: 56d2cc5a4643c4deb18573edfd4580398ccb6ccd96f0800f27240ef487d99daf7d95c83577a99754783e1ac233f3adb93b89b16b26d15303a5dd1ced32221825
|
|
@@ -14,7 +14,7 @@ require "dependabot/cargo/file_parser"
|
|
|
14
14
|
# https://doc.rust-lang.org/cargo/reference/manifest.html#the-workspace-section
|
|
15
15
|
module Dependabot
|
|
16
16
|
module Cargo
|
|
17
|
-
class FileFetcher < Dependabot::FileFetchers::Base
|
|
17
|
+
class FileFetcher < Dependabot::FileFetchers::Base # rubocop:disable Metrics/ClassLength
|
|
18
18
|
extend T::Sig
|
|
19
19
|
extend T::Helpers
|
|
20
20
|
|
|
@@ -50,13 +50,11 @@ module Dependabot
|
|
|
50
50
|
fetched_files << T.must(cargo_config) if cargo_config
|
|
51
51
|
fetched_files << T.must(rust_toolchain) if rust_toolchain
|
|
52
52
|
fetched_files += fetch_path_dependency_and_workspace_files
|
|
53
|
-
# If the main Cargo.toml uses workspace dependencies, ensure we have the workspace root
|
|
54
53
|
parsed_manifest = parsed_file(cargo_toml)
|
|
55
54
|
if uses_workspace_dependencies?(parsed_manifest) || workspace_member?(parsed_manifest)
|
|
56
55
|
workspace_root = find_workspace_root(cargo_toml)
|
|
57
56
|
fetched_files << workspace_root if workspace_root && !fetched_files.include?(workspace_root)
|
|
58
57
|
end
|
|
59
|
-
# Filter excluded files from final collection
|
|
60
58
|
fetched_files.reject do |file|
|
|
61
59
|
Dependabot::FileFiltering.should_exclude_path?(file.name, "file from final collection", @exclude_paths)
|
|
62
60
|
end.uniq
|
|
@@ -70,7 +68,10 @@ module Dependabot
|
|
|
70
68
|
def fetch_path_dependency_and_workspace_files(files = nil)
|
|
71
69
|
fetched_files = files || [cargo_toml]
|
|
72
70
|
fetched_files += path_dependency_files(fetched_files)
|
|
73
|
-
|
|
71
|
+
@workspace_files ||= T.let({}, T.nilable(T::Hash[String, T::Array[Dependabot::DependencyFile]]))
|
|
72
|
+
fetched_files += fetched_files.flat_map do |f|
|
|
73
|
+
@workspace_files[f.name] ||= fetch_workspace_files(file: f, previously_fetched_files: [])
|
|
74
|
+
end
|
|
74
75
|
updated_files = fetched_files.reject(&:support_file?).uniq
|
|
75
76
|
updated_files += fetched_files.uniq.reject { |f| updated_files.map(&:name).include?(f.name) }
|
|
76
77
|
return updated_files if updated_files == files
|
|
@@ -78,12 +79,6 @@ module Dependabot
|
|
|
78
79
|
fetch_path_dependency_and_workspace_files(updated_files)
|
|
79
80
|
end
|
|
80
81
|
|
|
81
|
-
sig { params(cargo_toml: Dependabot::DependencyFile).returns(T::Array[Dependabot::DependencyFile]) }
|
|
82
|
-
def workspace_files(cargo_toml)
|
|
83
|
-
@workspace_files ||= T.let({}, T.nilable(T::Hash[String, T::Array[Dependabot::DependencyFile]]))
|
|
84
|
-
@workspace_files[cargo_toml.name] ||= fetch_workspace_files(file: cargo_toml, previously_fetched_files: [])
|
|
85
|
-
end
|
|
86
|
-
|
|
87
82
|
sig { params(fetched_files: T::Array[Dependabot::DependencyFile]).returns(T::Array[Dependabot::DependencyFile]) }
|
|
88
83
|
def path_dependency_files(fetched_files)
|
|
89
84
|
@path_dependency_files ||= T.let({}, T.nilable(T::Hash[String, T::Array[Dependabot::DependencyFile]]))
|
|
@@ -442,6 +437,10 @@ module Dependabot
|
|
|
442
437
|
fetch_support_file(".cargo/config")&.tap { |f| f.name = ".cargo/config.toml" },
|
|
443
438
|
T.nilable(Dependabot::DependencyFile)
|
|
444
439
|
)
|
|
440
|
+
@cargo_config ||= T.let(
|
|
441
|
+
fetch_cargo_config_from_parent_dirs,
|
|
442
|
+
T.nilable(Dependabot::DependencyFile)
|
|
443
|
+
)
|
|
445
444
|
end
|
|
446
445
|
|
|
447
446
|
sig { returns(T.nilable(Dependabot::DependencyFile)) }
|
|
@@ -449,8 +448,6 @@ module Dependabot
|
|
|
449
448
|
return @rust_toolchain if defined?(@rust_toolchain)
|
|
450
449
|
|
|
451
450
|
@rust_toolchain = fetch_support_file("rust-toolchain")
|
|
452
|
-
# Per https://rust-lang.github.io/rustup/overrides.html the file can have a `.toml` extension,
|
|
453
|
-
# but the non-extension version is preferred. Renaming here to simplify finding it later in the code.
|
|
454
451
|
@rust_toolchain ||= T.let(
|
|
455
452
|
fetch_support_file("rust-toolchain.toml")&.tap { |f| f.name = "rust-toolchain" },
|
|
456
453
|
T.nilable(Dependabot::DependencyFile)
|
|
@@ -459,9 +456,7 @@ module Dependabot
|
|
|
459
456
|
|
|
460
457
|
sig { override.params(filename: T.any(Pathname, String)).returns(Dependabot::DependencyFile) }
|
|
461
458
|
def load_cloned_file_if_present(filename)
|
|
462
|
-
|
|
463
|
-
file.name = Pathname.new(file.name).cleanpath.to_s.gsub(%r{^/+}, "")
|
|
464
|
-
file
|
|
459
|
+
super.tap { |f| f.name = Pathname.new(f.name).cleanpath.to_s.gsub(%r{^/+}, "") }
|
|
465
460
|
end
|
|
466
461
|
|
|
467
462
|
sig do
|
|
@@ -472,9 +467,45 @@ module Dependabot
|
|
|
472
467
|
).returns(Dependabot::DependencyFile)
|
|
473
468
|
end
|
|
474
469
|
def fetch_file_from_host(filename, type: "file", fetch_submodules: false)
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
470
|
+
super.tap { |f| f.name = Pathname.new(f.name).cleanpath.to_s.gsub(%r{^/+}, "") }
|
|
471
|
+
end
|
|
472
|
+
|
|
473
|
+
sig { returns(T.nilable(Dependabot::DependencyFile)) }
|
|
474
|
+
def fetch_cargo_config_from_parent_dirs
|
|
475
|
+
return nil if directory.empty?
|
|
476
|
+
|
|
477
|
+
# Count directory depth to determine how many levels to search up
|
|
478
|
+
depth = directory.split("/").count { |s| !s.empty? }
|
|
479
|
+
return nil if depth.zero?
|
|
480
|
+
|
|
481
|
+
# Try each parent directory level
|
|
482
|
+
depth.times do |i|
|
|
483
|
+
parent_path = ([".."] * (i + 1)).join("/")
|
|
484
|
+
config = try_fetch_config_at_path(parent_path)
|
|
485
|
+
return config if config
|
|
486
|
+
end
|
|
487
|
+
|
|
488
|
+
nil
|
|
489
|
+
end
|
|
490
|
+
|
|
491
|
+
sig { params(parent_path: String).returns(T.nilable(Dependabot::DependencyFile)) }
|
|
492
|
+
def try_fetch_config_at_path(parent_path)
|
|
493
|
+
[".cargo/config.toml", ".cargo/config"].each do |config_name|
|
|
494
|
+
full_path = File.join(parent_path, config_name)
|
|
495
|
+
Dependabot.logger.debug("Attempting to fetch config from: #{full_path}")
|
|
496
|
+
config = fetch_file_from_host(
|
|
497
|
+
full_path,
|
|
498
|
+
fetch_submodules: false
|
|
499
|
+
)
|
|
500
|
+
Dependabot.logger.debug("Successfully fetched config from: #{full_path}")
|
|
501
|
+
config.support_file = true
|
|
502
|
+
config.name = ".cargo/config.toml"
|
|
503
|
+
return config
|
|
504
|
+
rescue Dependabot::DependencyFileNotFound
|
|
505
|
+
Dependabot.logger.debug("No config found at: #{full_path}")
|
|
506
|
+
next
|
|
507
|
+
end
|
|
508
|
+
nil
|
|
478
509
|
end
|
|
479
510
|
end
|
|
480
511
|
end
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: dependabot-cargo
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.356.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.
|
|
18
|
+
version: 0.356.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.
|
|
25
|
+
version: 0.356.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.
|
|
269
|
+
changelog_uri: https://github.com/dependabot/dependabot-core/releases/tag/v0.356.0
|
|
270
270
|
rdoc_options: []
|
|
271
271
|
require_paths:
|
|
272
272
|
- lib
|