lib/manageiq/cross_repo/repository.rb in manageiq-cross_repo-1.0.1 vs lib/manageiq/cross_repo/repository.rb in manageiq-cross_repo-1.0.2

- old
+ new

@@ -32,11 +32,11 @@ require "zlib" puts "Fetching #{tarball_url}" Dir.mktmpdir do |dir| - Mixlib::Archive.new(open(tarball_url, "rb")).extract(dir) + Mixlib::Archive.new(open_tarball_url(tarball_url)).extract(dir) content_dir = Pathname.new(dir).children.detect(&:directory?) FileUtils.mkdir_p(path.dirname) FileUtils.mv(content_dir, path) end @@ -143,9 +143,22 @@ return org, repo, ref, sha, url, path end def tarball_url url && File.join(url, "tarball", sha) + end + + def open_tarball_url(url) + archive = open(tarball_url, "rb") + + if archive.kind_of?(StringIO) + archive = Tempfile.new('cross_repo').tap do |f| + f.write(archive.string) + f.fsync + end.path + end + + archive end def git_branch_to_sha(url, branch) `git ls-remote #{url} #{branch}`.split("\t").first end