summaryrefslogtreecommitdiffstats
path: root/lib/git/lib.rb
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.corp.reactrix.com>2007-11-08 18:01:08 -0800
committerscott Chacon <schacon@agadorsparticus.corp.reactrix.com>2007-11-08 18:01:08 -0800
commitab20a674e50268b6c541949c746d77b16a26d15c (patch)
tree23e0f74748d79811e89ca9c63e2db58dedbe4636 /lib/git/lib.rb
parent10045d082117d4ef35da31e1c5a825507b02dd97 (diff)
downloadthird_party-ruby-git-ab20a674e50268b6c541949c746d77b16a26d15c.tar.gz
third_party-ruby-git-ab20a674e50268b6c541949c746d77b16a26d15c.tar.xz
third_party-ruby-git-ab20a674e50268b6c541949c746d77b16a26d15c.zip
added some branching beginnings
added tests for .size
Diffstat (limited to 'lib/git/lib.rb')
-rw-r--r--lib/git/lib.rb12
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