Class: Dependabot::GithubActions::FileFetcher
- Inherits:
-
FileFetchers::Base
- Object
- FileFetchers::Base
- Dependabot::GithubActions::FileFetcher
- Extended by:
- T::Helpers, T::Sig
- Defined in:
- lib/dependabot/github_actions/file_fetcher.rb
Class Method Summary collapse
Instance Method Summary collapse
- #fetch_files ⇒ Object
-
#initialize(source:, credentials:, repo_contents_path: nil, options: {}, update_config: nil) ⇒ FileFetcher
constructor
A new instance of FileFetcher.
Constructor Details
#initialize(source:, credentials:, repo_contents_path: nil, options: {}, update_config: nil) ⇒ FileFetcher
Returns a new instance of FileFetcher.
38 39 40 41 |
# File 'lib/dependabot/github_actions/file_fetcher.rb', line 38 def initialize(source:, credentials:, repo_contents_path: nil, options: {}, update_config: nil) @workflow_files = T.let([], T::Array[DependencyFile]) super end |
Class Method Details
.required_files_in?(filenames) ⇒ Boolean
18 19 20 |
# File 'lib/dependabot/github_actions/file_fetcher.rb', line 18 def self.required_files_in?(filenames) filenames.any? { |f| f.match?(MANIFEST_FILE_PATTERN) } end |
.required_files_message ⇒ Object
23 24 25 |
# File 'lib/dependabot/github_actions/file_fetcher.rb', line 23 def self. "Repo must contain a .github/workflows directory with YAML files or an action.yml file" end |
Instance Method Details
#fetch_files ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 |
# File 'lib/dependabot/github_actions/file_fetcher.rb', line 44 def fetch_files fetched_files = [] fetched_files += correctly_encoded_workflow_files if fetched_files.any? # The lockfile is additive: it is only fetched alongside workflow files # and never activates the ecosystem on its own. Relocking also requires # every workflow to be materialized, so retain the workflow-only path if # an invalidly encoded workflow had to be omitted. fetched_files += [actions_lockfile].compact if incorrectly_encoded_workflow_files.empty? return fetched_files end if incorrectly_encoded_workflow_files.none? expected_paths = if directory == "/" File.join(directory, MANIFEST_FILE_YML) + " or /#{CONFIG_YMLS}" else File.join(directory, ANYTHING_YML) end raise( Dependabot::DependencyFileNotFound, expected_paths ) else raise( Dependabot::DependencyFileNotParseable, T.must(incorrectly_encoded_workflow_files.first).path ) end end |