Class: Dependabot::GitSubmodules::FileParser

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

Instance Method Summary collapse

Instance Method Details

#parseObject


12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/dependabot/git_submodules/file_parser.rb', line 12

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

    ParseConfig.new(".gitmodules").params.map do |_, params|
      branch = params["branch"]

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