Sha256: 90855f8fb53220e841e8708f29a66bf96c627053b349845f3f7f9bc20f6824e3

Contents?: true

Size: 1.7 KB

Versions: 4

Compression:

Stored size: 1.7 KB

Contents

# frozen_string_literal: true

require 'puppetfile-resolver/util'
require 'puppetfile-resolver/spec_searchers/common'
require 'puppetfile-resolver/spec_searchers/git_configuration'
require 'puppetfile-resolver/spec_searchers/git/github'
require 'puppetfile-resolver/spec_searchers/git/gitlab'
require 'puppetfile-resolver/spec_searchers/git/gclone'

module PuppetfileResolver
  module SpecSearchers
    module Git
      def self.find_all(puppetfile_module, dependency, cache, resolver_ui, config)
        dep_id = ::PuppetfileResolver::SpecSearchers::Common.dependency_cache_id(self, dependency)
        # Has the information been cached?
        return cache.load(dep_id) if cache.exist?(dep_id)

        # The git clone method takes around (1s) depending on repo size.  Not sure if the
        # other methods take longer or shorter but I preserved the legacy code for now.
        # Technically, the gclone class could replace the other classes and speed up
        # this process here.
        metadata = GitHub.metadata(puppetfile_module, resolver_ui, config) ||
                   GitLab.metadata(puppetfile_module, resolver_ui, config) ||
                   GClone.metadata(puppetfile_module, resolver_ui, config)

        if metadata.nil? || metadata.empty?
          # Cache that we couldn't find the metadata
          cache.save(dep_id, [])
          return []
        end

        metadata = ::PuppetfileResolver::Util.symbolise_object(::JSON.parse(metadata))
        result = [Models::ModuleSpecification.new(
          name: metadata[:name],
          origin: :git,
          version: metadata[:version],
          metadata: metadata
        )]

        cache.save(dep_id, result)

        result
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
puppetfile-resolver-0.6.3 lib/puppetfile-resolver/spec_searchers/git.rb
puppetfile-resolver-0.6.2 lib/puppetfile-resolver/spec_searchers/git.rb
puppetfile-resolver-0.6.1 lib/puppetfile-resolver/spec_searchers/git.rb
puppetfile-resolver-0.6.0 lib/puppetfile-resolver/spec_searchers/git.rb