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

#parseObject



18
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
# File 'lib/dependabot/git_submodules/file_parser.rb', line 18

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