From d07a2c04c1599fe707831afdd29397cc36e02fa6 Mon Sep 17 00:00:00 2001 From: scott Chacon Date: Tue, 20 Nov 2007 12:07:46 -0800 Subject: added files from the gitrb project, which seems abandoned, but which is great code --- tests/units/test_raw_internals.rb | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 tests/units/test_raw_internals.rb (limited to 'tests/units') diff --git a/tests/units/test_raw_internals.rb b/tests/units/test_raw_internals.rb new file mode 100644 index 0000000..b135e52 --- /dev/null +++ b/tests/units/test_raw_internals.rb @@ -0,0 +1,15 @@ +#!/usr/bin/env ruby + +require File.dirname(__FILE__) + '/../test_helper' + +class TestRawInternals < Test::Unit::TestCase + + def setup + set_file_paths + @git = Git.open(@wdir) + end + + def test_raw_log + end + +end \ No newline at end of file -- cgit From 90dea6d415bfc5734bc87c2797b26cca311246bc Mon Sep 17 00:00:00 2001 From: scott Chacon Date: Tue, 20 Nov 2007 13:24:44 -0800 Subject: have the pure ruby bindings working to some degree --- tests/units/test_raw_internals.rb | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'tests/units') diff --git a/tests/units/test_raw_internals.rb b/tests/units/test_raw_internals.rb index b135e52..4299a2b 100644 --- a/tests/units/test_raw_internals.rb +++ b/tests/units/test_raw_internals.rb @@ -6,10 +6,30 @@ class TestRawInternals < Test::Unit::TestCase def setup set_file_paths - @git = Git.open(@wdir) end def test_raw_log + g = Git.bare(@wbare) + #g.repack + + c = g.object("HEAD") + puts sha = c.sha + + repo = Git::Raw::Repository.new(@wbare) + while sha do + o = repo.get_raw_object_by_sha1(sha) + c = Git::Raw::Object.from_raw(o) + + sha = c.parent.first + puts sha + end + + g.log(60).each do |c| + puts c.sha + end + + puts c.inspect + end end \ No newline at end of file -- cgit From f1366b39891402b0db9de661ad181089bfd79053 Mon Sep 17 00:00:00 2001 From: scott Chacon Date: Fri, 23 Nov 2007 11:16:46 -0800 Subject: got log and cat-file moved to pure ruby --- tests/units/test_raw_internals.rb | 41 ++++++++++++++++++++++----------------- 1 file changed, 23 insertions(+), 18 deletions(-) (limited to 'tests/units') diff --git a/tests/units/test_raw_internals.rb b/tests/units/test_raw_internals.rb index 4299a2b..1437845 100644 --- a/tests/units/test_raw_internals.rb +++ b/tests/units/test_raw_internals.rb @@ -1,5 +1,5 @@ #!/usr/bin/env ruby - +require 'logger' require File.dirname(__FILE__) + '/../test_helper' class TestRawInternals < Test::Unit::TestCase @@ -10,26 +10,31 @@ class TestRawInternals < Test::Unit::TestCase def test_raw_log g = Git.bare(@wbare) - #g.repack + t_log(g) + end + + def test_packed_log + g = Git.bare(@wbare) + g.repack + t_log(g) + end + + def test_commit_object + g = Git.bare(@wbare, :log => Logger.new(STDOUT)) - c = g.object("HEAD") - puts sha = c.sha + c = g.gcommit("v2.5") + assert_equal('test', c.message) + end + + def t_log(g) + c = g.object("v2.5") + sha = c.sha repo = Git::Raw::Repository.new(@wbare) - while sha do - o = repo.get_raw_object_by_sha1(sha) - c = Git::Raw::Object.from_raw(o) - - sha = c.parent.first - puts sha - end - - g.log(60).each do |c| - puts c.sha - end - - puts c.inspect + 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 -- cgit From 07ebb951368ed31bdaebc2e820c62ced22c8bbe4 Mon Sep 17 00:00:00 2001 From: scott Chacon Date: Tue, 27 Nov 2007 08:06:51 -0800 Subject: 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 --- tests/units/test_index_ops.rb | 2 +- tests/units/test_lib.rb | 9 +++++++++ tests/units/test_raw_internals.rb | 26 ++++++++++++++++++++------ 3 files changed, 30 insertions(+), 7 deletions(-) (limited to 'tests/units') 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 -- cgit From 6a9db968e8563bc27b8f56f9d413159a2e14cf67 Mon Sep 17 00:00:00 2001 From: scott Chacon Date: Tue, 27 Nov 2007 08:21:28 -0800 Subject: fixed issue with running a 'git log' with an object that won't rev-parse (file) --- tests/units/test_log.rb | 3 ++- tests/units/test_raw_internals.rb | 5 ++--- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/units') diff --git a/tests/units/test_log.rb b/tests/units/test_log.rb index 11dcb27..7bcd83b 100644 --- a/tests/units/test_log.rb +++ b/tests/units/test_log.rb @@ -1,10 +1,11 @@ #!/usr/bin/env ruby - +require 'logger' require File.dirname(__FILE__) + '/../test_helper' class TestLog < Test::Unit::TestCase def setup set_file_paths + #@git = Git.open(@wdir, :log => Logger.new(STDOUT)) @git = Git.open(@wdir) end diff --git a/tests/units/test_raw_internals.rb b/tests/units/test_raw_internals.rb index 03a7916..b37a66d 100644 --- a/tests/units/test_raw_internals.rb +++ b/tests/units/test_raw_internals.rb @@ -22,8 +22,7 @@ class TestRawInternals < Test::Unit::TestCase end def test_commit_object - g = Git.bare(@wbare, :log => Logger.new(STDOUT)) - + g = Git.bare(@wbare) c = g.gcommit("v2.5") assert_equal('test', c.message) end @@ -34,7 +33,7 @@ class TestRawInternals < Test::Unit::TestCase sha = c.sha repo = Git::Raw::Repository.new(@wbare) - puts repo.object(sha).inspect + assert_equal('ex_dir', repo.object(sha).entry.first.name) end def t_log(g) -- cgit