3 require File.dirname(__FILE__) + '/../lib/git'
5 class Test::Unit::TestCase
9 if File.directory?(File.join(cwd, 'files'))
10 @test_dir = File.join(cwd, 'files')
11 elsif File.directory?(File.join(cwd, '..', 'files'))
12 @test_dir = File.join(cwd, '..', 'files')
13 elsif File.directory?(File.join(cwd, 'tests', 'files'))
14 @test_dir = File.join(cwd, 'tests', 'files')
17 @wdir = File.expand_path(File.join(@test_dir, 'working'))
18 @wbare = File.expand_path(File.join(@test_dir, 'working.git'))
19 @index = File.expand_path(File.join(@test_dir, 'index'))
22 def in_temp_dir(remove_after = true)
23 filename = 'git_test' + Time.now.to_i.to_s + rand(300).to_s
24 tmp_path = File.join("/tmp/", filename)
25 FileUtils.mkdir(tmp_path)
29 FileUtils.rm_r(tmp_path) if remove_after
33 def new_file(name, contents)
34 File.open(name, 'w') do |f|
39 def append_file(name, contents)
40 File.open(name, 'a') do |f|