summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.(none)>2007-11-27 08:06:51 -0800
committerscott Chacon <schacon@agadorsparticus.(none)>2007-11-27 08:06:51 -0800
commit07ebb951368ed31bdaebc2e820c62ced22c8bbe4 (patch)
tree729d483ad8f66cf7907bedbb2d01dec6d2856654 /tests
parent3fddf300bd33b356540bee50ae17590ea9b61341 (diff)
downloadthird_party-ruby-git-07ebb951368ed31bdaebc2e820c62ced22c8bbe4.tar.gz
third_party-ruby-git-07ebb951368ed31bdaebc2e820c62ced22c8bbe4.tar.xz
third_party-ruby-git-07ebb951368ed31bdaebc2e820c62ced22c8bbe4.zip
added Matthias and Simon to credits for the gitrb code
fixed an issue with raw object tree formatting added ls_tree implementation in raw git
Diffstat (limited to 'tests')
-rw-r--r--tests/test_helper.rb10
-rw-r--r--tests/units/test_index_ops.rb2
-rw-r--r--tests/units/test_lib.rb9
-rw-r--r--tests/units/test_raw_internals.rb26
4 files changed, 40 insertions, 7 deletions
diff --git a/tests/test_helper.rb b/tests/test_helper.rb
index 9907ffe..e40174a 100644
--- a/tests/test_helper.rb
+++ b/tests/test_helper.rb
@@ -28,6 +28,16 @@ class Test::Unit::TestCase
end
end
+
+ def with_temp_bare
+ in_temp_dir do |path|
+ g = Git.clone(@wbare, 'new')
+ Dir.chdir('new') do
+ yield g
+ end
+ end
+ end
+
def create_temp_repo(clone_path)
filename = 'git_test' + Time.now.to_i.to_s + rand(300).to_s.rjust(3, '0')
@tmp_path = File.join("/tmp/", filename)
diff --git a/tests/units/test_index_ops.rb b/tests/units/test_index_ops.rb
index f92ae9e..dcd8498 100644
--- a/tests/units/test_index_ops.rb
+++ b/tests/units/test_index_ops.rb
@@ -10,7 +10,7 @@ class TestIndexOps < Test::Unit::TestCase
end
def test_add
- in_temp_dir(false) do |path|
+ in_temp_dir do |path|
g = Git.clone(@wbare, 'new')
Dir.chdir('new') do
assert_equal('100644', g.status['example.txt'].mode_index)
diff --git a/tests/units/test_lib.rb b/tests/units/test_lib.rb
index f9170e6..7cbbeef 100644
--- a/tests/units/test_lib.rb
+++ b/tests/units/test_lib.rb
@@ -102,6 +102,15 @@ class TestLib < Test::Unit::TestCase
assert_equal('+refs/heads/*:refs/remotes/working/*', config['fetch'])
end
+
+ def test_ls_tree
+ tree = @lib.ls_tree('94c827875e2cadb8bc8d4cdd900f19aa9e8634c7')
+ assert_equal("3aac4b445017a8fc07502670ec2dbf744213dd48", tree['blob']['example.txt'][:sha])
+ assert_equal("100644", tree['blob']['example.txt'][:mode])
+ assert(tree['tree'])
+ end
+
+
# options this will accept
# :treeish
# :path_limiter
diff --git a/tests/units/test_raw_internals.rb b/tests/units/test_raw_internals.rb
index 1437845..03a7916 100644
--- a/tests/units/test_raw_internals.rb
+++ b/tests/units/test_raw_internals.rb
@@ -9,14 +9,16 @@ class TestRawInternals < Test::Unit::TestCase
end
def test_raw_log
- g = Git.bare(@wbare)
- t_log(g)
+ with_temp_bare do |g|
+ t_log(g)
+ end
end
def test_packed_log
- g = Git.bare(@wbare)
- g.repack
- t_log(g)
+ with_temp_bare do |g|
+ g.repack
+ t_log(g)
+ end
end
def test_commit_object
@@ -26,15 +28,27 @@ class TestRawInternals < Test::Unit::TestCase
assert_equal('test', c.message)
end
+ def test_lstree
+ g = Git.bare(@wbare)
+ c = g.object("v2.5").gtree
+ sha = c.sha
+
+ repo = Git::Raw::Repository.new(@wbare)
+ puts repo.object(sha).inspect
+ end
+
def t_log(g)
c = g.object("v2.5")
sha = c.sha
- repo = Git::Raw::Repository.new(@wbare)
+ repo = Git::Raw::Repository.new(g.repo.path)
raw_out = repo.log(sha)
assert_equal('commit 546bec6f8872efa41d5d97a369f669165ecda0de', raw_out.split("\n").first)
assert_equal('546bec6f8872efa41d5d97a369f669165ecda0de', c.log(30).first.sha)
end
+
+
+
end \ No newline at end of file