Sha256: c6cc4dbd0c4337d6aae2470a17ed80af6c89b2c2be79c0f6a0bfac70ea256fce
Contents?: true
Size: 1.89 KB
Versions: 2
Compression:
Stored size: 1.89 KB
Contents
# frozen_string_literal: true require 'puppetfile-resolver/util' require 'puppetfile-resolver/spec_searchers/common' require 'puppetfile-resolver/spec_searchers/git_configuration' module PuppetfileResolver module SpecSearchers module Git module GitHub def self.metadata(puppetfile_module, resolver_ui, config) repo_url = nil if puppetfile_module.remote.start_with?('git@github.com:') repo_url = puppetfile_module.remote.slice(15..-1) repo_url = repo_url.slice(0..-5) if repo_url.end_with?('.git') elsif puppetfile_module.remote.start_with?('https://github.com/') repo_url = puppetfile_module.remote.slice(19..-1) repo_url = repo_url.slice(0..-5) if repo_url.end_with?('.git') end return nil if repo_url.nil? metadata_url = 'https://raw.githubusercontent.com/' + repo_url + '/' if puppetfile_module.ref metadata_url += puppetfile_module.ref + '/' elsif puppetfile_module.tag metadata_url += puppetfile_module.tag + '/' else # Default to master. Should it raise? metadata_url += 'master/' end metadata_url += 'metadata.json' resolver_ui.debug { "Querying GitHub with #{metadata_url}" } err_msg = "Unable to find module at #{puppetfile_module.remote}" err_msg += config.proxy ? " with proxy #{config.proxy}: " : ': ' response = nil begin response = ::PuppetfileResolver::Util.net_http_get(metadata_url, config.proxy) rescue ::StandardError => e raise err_msg + e.message end if response.code != '200' resolver_ui.debug(err_msg + "Expected HTTP Code 200, but received #{response.code}") return nil end response.body end end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
puppetfile-resolver-0.6.2 | lib/puppetfile-resolver/spec_searchers/git/github.rb |
puppetfile-resolver-0.6.1 | lib/puppetfile-resolver/spec_searchers/git/github.rb |