Class: Dependabot::Config::FileFetcher
- Inherits:
-
FileFetchers::Base
- Object
- FileFetchers::Base
- Dependabot::Config::FileFetcher
- Extended by:
- T::Sig
- Defined in:
- lib/dependabot/config/file_fetcher.rb
Constant Summary collapse
- CONFIG_FILE_PATHS =
T.let(%w(.github/dependabot.yml .github/dependabot.yaml).freeze, T::Array[String])
Constants inherited from FileFetchers::Base
FileFetchers::Base::CLIENT_NOT_FOUND_ERRORS, FileFetchers::Base::GIT_RETRYABLE_ERRORS, FileFetchers::Base::GIT_SUBMODULE_CLONE_ERROR, FileFetchers::Base::GIT_SUBMODULE_ERROR_REGEX, FileFetchers::Base::GIT_SUBMODULE_INACCESSIBLE_ERROR
Instance Attribute Summary
Attributes inherited from FileFetchers::Base
#credentials, #options, #repo_contents_path, #source
Class Method Summary collapse
Instance Method Summary collapse
Methods inherited from FileFetchers::Base
#allow_beta_ecosystems?, #clone_repo_contents, #commit, #directory, #ecosystem_versions, #exclude_paths=, #files, #initialize, #repo, #target_branch
Constructor Details
This class inherits a constructor from Dependabot::FileFetchers::Base
Class Method Details
.required_files_in?(filenames) ⇒ Boolean
16 17 18 |
# File 'lib/dependabot/config/file_fetcher.rb', line 16 def self.required_files_in?(filenames) CONFIG_FILE_PATHS.any? { |file| filenames.include?(file) } end |
.required_files_message ⇒ Object
21 22 23 |
# File 'lib/dependabot/config/file_fetcher.rb', line 21 def self. "Repo must contain either a #{CONFIG_FILE_PATHS.join(' or a ')} file" end |
Instance Method Details
#config_file ⇒ Object
26 27 28 |
# File 'lib/dependabot/config/file_fetcher.rb', line 26 def config_file @config_file ||= T.let(files.first, T.nilable(Dependabot::DependencyFile)) end |
#fetch_files ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/dependabot/config/file_fetcher.rb', line 31 def fetch_files fetched_files = T.let([], T::Array[Dependabot::DependencyFile]) CONFIG_FILE_PATHS.each do |file| fn = Pathname.new("/#{file}").relative_path_from(directory) begin config_file = fetch_file_from_host(fn) if config_file fetched_files << config_file break end rescue DependencyFileNotFound next end end unless self.class.required_files_in?(fetched_files.map(&:name)) raise DependencyFileNotFound.new(nil, self.class.) end fetched_files end |