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)


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

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

.required_files_messageObject



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

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

Instance Method Details

#ecosystem_versionsObject



25
26
27
28
29
30
31
# File 'lib/dependabot/go_modules/file_fetcher.rb', line 25

def ecosystem_versions
  {
    package_managers: {
      "gomod" => go_mod&.content&.match(/^go\s(\d+\.\d+)/)&.captures&.first || "unknown"
    }
  }
end

#fetch_filesObject



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/dependabot/go_modules/file_fetcher.rb', line 34

def fetch_files
  # Ensure we always check out the full repo contents for go_module
  # updates.
  SharedHelpers.in_a_temporary_repo_directory(
    directory,
    clone_repo_contents
  ) do
    fetched_files = go_mod ? [go_mod] : []
    # Fetch the (optional) go.sum
    fetched_files << T.must(go_sum) if go_sum
    fetched_files
  end
end