Sha256: be5cc8c76665eddcaf457729c80f5015f89a15dfecfdc903be9ddd7314c0eb25

Contents?: true

Size: 1.45 KB

Versions: 28

Compression:

Stored size: 1.45 KB

Contents

#!/usr/bin/env ruby

require File.dirname(__FILE__) + '/../test_helper'

class TestArchive < Test::Unit::TestCase
  
  def setup
    set_file_paths
    @git = Git.open(@wdir)
  end
  
  def tempfile
    Tempfile.new('archive-test').path
  end
  
  def test_archive
    f = @git.archive('v2.6', tempfile)
    assert(File.exists?(f))

    f = @git.object('v2.6').archive(tempfile)  # writes to given file
    assert(File.exists?(f))

    f = @git.object('v2.6').archive # returns path to temp file
    assert(File.exists?(f))
    
    f = @git.object('v2.6').archive(nil, :format => 'tar') # returns path to temp file
    assert(File.exists?(f))
    
    lines = `cd /tmp; tar xvpf #{f}`.split("\n")
    assert_equal('ex_dir/', lines[0])
    assert_equal('example.txt', lines[2])
    
    f = @git.object('v2.6').archive(tempfile, :format => 'zip')
    assert(File.file?(f))

    f = @git.object('v2.6').archive(tempfile, :format => 'tgz', :prefix => 'test/')
    assert(File.exists?(f))
    
    f = @git.object('v2.6').archive(tempfile, :format => 'tar', :prefix => 'test/', :path => 'ex_dir/')
    assert(File.exists?(f))
    
    lines = `cd /tmp; tar xvpf #{f}`.split("\n")
    assert_equal('test/', lines[0])
    assert_equal('test/ex_dir/ex.txt', lines[2])

    in_temp_dir do
      c = Git.clone(@wbare, 'new')
      c.chdir do
        f = @git.remote('origin').branch('master').archive(tempfile, :format => 'tgz')
        assert(File.exists?(f))
      end
    end
  end
  
end

Version data entries

28 entries across 28 versions & 4 rubygems

Version Path
titanous-git-1.1.0 tests/units/test_archive.rb
redcar-dev-0.12.1dev-java plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-dev-0.12.0dev-java plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.11 plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.11.0dev plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.10 plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.9.2 plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.9.1 plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.9.0 plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.8.1 plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.8 plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.7 plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.6.1 plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.6 plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.6.1dev plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.5.1 plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.5 plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.5.6dev plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.5.5dev plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb
redcar-0.5.4dev plugins/scm_git/vendor/ruby-git/tests/units/test_archive.rb