Class: Dependabot::GoModules::FileFetcher

Inherits:
FileFetchers::Base
  • Object
show all
Extended by:
T::Helpers, T::Sig
Defined in:
lib/dependabot/go_modules/file_fetcher.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.required_files_in?(filenames) ⇒ Boolean

Returns:

  • (Boolean)


16
17
18
# File 'lib/dependabot/go_modules/file_fetcher.rb', line 16

def self.required_files_in?(filenames)
  filenames.include?("go.mod") || filenames.include?("go.work")
end

.required_files_messageObject



21
22
23
# File 'lib/dependabot/go_modules/file_fetcher.rb', line 21

def self.required_files_message
  "Repo must contain a go.mod or go.work."
end

Instance Method Details

#ecosystem_versionsObject



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dependabot/go_modules/file_fetcher.rb', line 26

def ecosystem_versions
  version = go_version_from_file(go_mod) ||
            go_version_from_file(go_work) ||
            all_workspace_go_mods.filter_map { |f| go_version_from_file(f) }.first ||
            "unknown"

  {
    package_managers: {
      "gomod" => version
    }
  }
end

#fetch_filesObject



40
41
42
43
44
45
46
# File 'lib/dependabot/go_modules/file_fetcher.rb', line 40

def fetch_files
  SharedHelpers.in_a_temporary_repo_directory(directory, clone_repo_contents) do
    fetched_files = collect_dependency_files
    validate_files!(fetched_files)
    fetched_files
  end
end