class Dependabot::GithubActions::FileFetcher

Public Class Methods

required_files_in?(filenames) click to toggle source
# File lib/dependabot/github_actions/file_fetcher.rb, line 9
def self.required_files_in?(filenames)
  filenames.any? { |f| f == ".github" }
end
required_files_message() click to toggle source
# File lib/dependabot/github_actions/file_fetcher.rb, line 13
def self.required_files_message
  "Repo must contain a .github/workflows directory with YAML files."
end

Private Instance Methods

correctly_encoded_workflow_files() click to toggle source
# File lib/dependabot/github_actions/file_fetcher.rb, line 51
def correctly_encoded_workflow_files
  workflow_files.select { |f| f.content.valid_encoding? }
end
fetch_files() click to toggle source
# File lib/dependabot/github_actions/file_fetcher.rb, line 19
def fetch_files
  fetched_files = []
  fetched_files += correctly_encoded_workflow_files
  fetched_files += referenced_local_workflow_files

  return fetched_files if fetched_files.any?

  if incorrectly_encoded_workflow_files.none?
    raise(
      Dependabot::DependencyFileNotFound,
      File.join(directory, ".github/workflows/<anything>.yml")
    )
  else
    raise(
      Dependabot::DependencyFileNotParseable,
      incorrectly_encoded_workflow_files.first.path
    )
  end
end
incorrectly_encoded_workflow_files() click to toggle source
# File lib/dependabot/github_actions/file_fetcher.rb, line 55
def incorrectly_encoded_workflow_files
  workflow_files.reject { |f| f.content.valid_encoding? }
end
referenced_local_workflow_files() click to toggle source
# File lib/dependabot/github_actions/file_fetcher.rb, line 46
def referenced_local_workflow_files
  # TODO: Fetch referenced local workflow files
  []
end
workflow_files() click to toggle source
# File lib/dependabot/github_actions/file_fetcher.rb, line 39
def workflow_files
  @workflow_files ||=
    repo_contents(dir: ".github/workflows", raise_errors: false).
    select { |f| f.type == "file" && f.name.match?(/\.ya?ml$/) }.
    map { |f| fetch_file_from_host(".github/workflows/#{f.name}") }
end