Class: Dependabot::Cargo::FileFetcher
- Inherits:
-
FileFetchers::Base
- Object
- FileFetchers::Base
- Dependabot::Cargo::FileFetcher
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/dependabot/cargo/file_fetcher.rb
Overview
rubocop:disable Metrics/ClassLength
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.required_files_in?(filenames) ⇒ Boolean
22 23 24 |
# File 'lib/dependabot/cargo/file_fetcher.rb', line 22 def self.required_files_in?(filenames) filenames.include?("Cargo.toml") end |
.required_files_message ⇒ Object
27 28 29 |
# File 'lib/dependabot/cargo/file_fetcher.rb', line 27 def self. "Repo must contain a Cargo.toml." end |
Instance Method Details
#ecosystem_versions ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'lib/dependabot/cargo/file_fetcher.rb', line 32 def ecosystem_versions channel = if rust_toolchain TomlRB.parse(T.must(rust_toolchain).content).dig("toolchain", "channel") else "default" end { package_managers: { "cargo" => channel } } rescue TomlRB::ParseError raise Dependabot::DependencyFileNotParseable.new( T.must(rust_toolchain).path, "only rust-toolchain files formatted as TOML are supported, the non-TOML format was deprecated by Rust" ) end |
#fetch_files ⇒ Object
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 |
# File 'lib/dependabot/cargo/file_fetcher.rb', line 47 def fetch_files fetched_files = T.let([cargo_toml], T::Array[DependencyFile]) fetched_files << T.must(cargo_lock) if cargo_lock fetched_files << T.must(cargo_config) if cargo_config fetched_files << T.must(rust_toolchain) if rust_toolchain fetched_files += fetch_path_dependency_and_workspace_files parsed_manifest = parsed_file(cargo_toml) if uses_workspace_dependencies?(parsed_manifest) || workspace_member?(parsed_manifest) workspace_root = find_workspace_root(cargo_toml) fetched_files << workspace_root if workspace_root && !fetched_files.include?(workspace_root) end fetched_files.reject do |file| Dependabot::FileFiltering.should_exclude_path?(file.name, "file from final collection", @exclude_paths) end.uniq end |