From ab20a674e50268b6c541949c746d77b16a26d15c Mon Sep 17 00:00:00 2001 From: scott Chacon Date: Thu, 8 Nov 2007 18:01:08 -0800 Subject: added some branching beginnings added tests for .size --- lib/git/lib.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'lib/git/lib.rb') diff --git a/lib/git/lib.rb b/lib/git/lib.rb index 681ba58..c83ecaa 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -18,7 +18,7 @@ module Git arr_opts << "#{opts[:between][0]}..#{opts[:between][1].to_s}" if (opts[:between] && opts[:between].size == 2) arr_opts << opts[:file] if opts[:file].is_a? String - command('log', arr_opts).split("\n").map { |l| Git::Object::Commit.new(@base, l.split.first) } + command_lines('log', arr_opts).map { |l| Git::Object::Commit.new(@base, l.split.first) } end def revparse(string) @@ -30,15 +30,23 @@ module Git end def object_size(sha) - command('cat-file', ['-s', sha]) + command('cat-file', ['-s', sha]).to_i end def object_contents(sha) command('cat-file', ['-p', sha]) end + + def branches_all + command_lines('branch', '-a').map { |l| Git::Branch.new(@base, l) } + end private + def command_lines(cmd, opts) + command(cmd, opts).split("\n") + end + def command(cmd, opts) ENV['GIT_DIR'] = @base.repo.path ENV['GIT_INDEX_FILE'] = @base.index.path -- cgit