Sha256: b01f09c76f0aa6c60c3e48a064acb1eefc7f7612a3e402e889822af03a2e0595
Contents?: true
Size: 882 Bytes
Versions: 1
Compression:
Stored size: 882 Bytes
Contents
require 'git' require 'open-uri' module OpenStax::Aws module GitHelper def self.sha_for_branch_name(org_slash_repo:, branch:) ::Git.ls_remote("https://github.com/#{org_slash_repo}")["branches"][branch][:sha] end def self.file_content_at_sha(org_slash_repo:, sha:, path:, github_token: nil ) if github_token.blank? location = "https://raw.githubusercontent.com/#{org_slash_repo}/#{sha}/#{path}" file = open(location) file.read else uri = URI("https://raw.githubusercontent.com/#{org_slash_repo}/#{sha}/#{path}") Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http| request = Net::HTTP::Get.new uri.request_uri request.basic_auth 'token', github_token response = http.request request response.body end end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
openstax_aws-1.3.0 | lib/openstax/aws/git_helper.rb |