diff options
Diffstat (limited to 'lib/git/lib.rb')
-rw-r--r-- | lib/git/lib.rb | 12 |
1 files changed, 10 insertions, 2 deletions
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 |