Skip to content

Commit 577b265

Browse files
committed
Fix archive extraction
1 parent c8e9ad8 commit 577b265

File tree

2 files changed

+6
-6
lines changed

2 files changed

+6
-6
lines changed
Binary file not shown.

spec/octocatalog-diff/tests/spec_helper.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
require 'logger'
33
require 'rspec'
44
require 'rspec/retry'
5+
require 'rubygems/package'
56
require 'tempfile'
67
require 'tmpdir'
78

@@ -210,23 +211,22 @@ def self.test_command(command)
210211
# Check out fixture repo. The repository is a tarball; this extracts it to a temporary directory and returns
211212
# the path where it was checked out. If the checkout fails, returns nil. Note: Be sure to include code in the
212213
# caller to clean up the temporary directory upon exit.
213-
# @param repo [String] Name of repository (in fixtures/git-repos/{repo}.tar)
214+
# @param repo [String] Name of repository (in fixtures/git-repos/{repo}.tgz)
214215
# @return [String] Path to checkout
215216
def self.extract_fixture_repo(repo)
216217
# If tar isn't here, don't do this
217218
has_tar = test_command('tar --version')
218219
return nil unless has_tar.nil?
219220

220221
# Make sure tarball is there
221-
repo_tarball = fixture_path("git-repos/#{repo}.tar")
222+
repo_tarball = fixture_path("git-repos/#{repo}.tgz")
222223
raise Errno::ENOENT, "Repo tarball for #{repo} not found in #{repo_tarball}" unless File.file?(repo_tarball)
223224

224225
# Extract to temporary directory
225226
extract_dir = Dir.mktmpdir
226-
cmd = "tar -xf #{Shellwords.escape(repo_tarball)}"
227-
extract_result, extract_code = Open3.capture2e(cmd, chdir: extract_dir)
228-
return extract_dir if extract_code.exitstatus.zero?
229-
raise "Failed to extract #{repo_tarball}: #{extract_result} (#{extract_code.exitstatus})"
227+
io = File.open(repo_tarball, 'rb')
228+
Gem::Package.new("").extract_tar_gz(io, extract_dir)
229+
return extract_dir
230230
end
231231

232232
# Clean up a temporary directory. This does nothing if the directory doesn't exist, or if it's nil.

0 commit comments

Comments
 (0)