3 require File.dirname(__FILE__) + '/../test_helper'
5 class TestArchive < Test::Unit::TestCase
13 Tempfile.new('archive-test').path
17 f = @git.archive('v2.6', tempfile)
18 assert(File.exists?(f))
20 f = @git.object('v2.6').archive(tempfile) # writes to given file
21 assert(File.exists?(f))
23 f = @git.object('v2.6').archive # returns path to temp file
24 assert(File.exists?(f))
26 f = @git.object('v2.6').archive(nil, :format => 'tar') # returns path to temp file
27 assert(File.exists?(f))
29 lines = `cd /tmp; tar xvpf #{f}`.split("\n")
30 assert_equal('ex_dir/', lines[0])
31 assert_equal('example.txt', lines[2])
33 f = @git.object('v2.6').archive(tempfile, :format => 'zip')
36 f = @git.object('v2.6').archive(tempfile, :format => 'tgz', :prefix => 'test/')
37 assert(File.exists?(f))
39 f = @git.object('v2.6').archive(tempfile, :format => 'tar', :prefix => 'test/', :path => 'ex_dir/')
40 assert(File.exists?(f))
42 lines = `cd /tmp; tar xvpf #{f}`.split("\n")
43 assert_equal('test/', lines[0])
44 assert_equal('test/ex_dir/ex.txt', lines[2])
47 c = Git.clone(@wbare, 'new')
49 f = @git.remote('origin').branch('master').archive(tempfile, :format => 'tgz')
50 assert(File.exists?(f))