Class: Dependabot::GitSubmodules::FileParser

Inherits:
FileParsers::Base
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/dependabot/git_submodules/file_parser.rb

Instance Method Summary collapse

Instance Method Details

#ecosystemObject



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/dependabot/git_submodules/file_parser.rb', line 47

def ecosystem
  @ecosystem ||= T.let(
    begin
      Ecosystem.new(
        name: ECOSYSTEM,
        package_manager: package_manager
      )
    end,
    T.nilable(Dependabot::Ecosystem)
  )
end

#parseObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# File 'lib/dependabot/git_submodules/file_parser.rb', line 19

def parse
  Dependabot::SharedHelpers.in_a_temporary_directory do
    File.write(".gitmodules", gitmodules_file.content)

    ParseConfig.new(".gitmodules").params.map do |_, params|
      raise DependencyFileNotParseable, gitmodules_file.path if params.fetch("path").end_with?("/")

      Dependency.new(
        name: params.fetch("path"),
        version: submodule_sha(params.fetch("path")),
        package_manager: "submodules",
        requirements: [{
          requirement: nil,
          file: ".gitmodules",
          source: {
            type: "git",
            url: absolute_url(params["url"]),
            branch: params["branch"],
            ref: params["branch"]
          },
          groups: []
        }]
      )
    end
  end
end