From 9d59d2965184964ab6662282ef5f9ceac2c58552 Mon Sep 17 00:00:00 2001 From: scott Chacon Date: Fri, 9 Nov 2007 13:11:22 -0800 Subject: added branches, more log stuff, better tests, changed the log api a bit added tests for Git::Lib, started Git::Diff development --- lib/git/branches.rb | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) (limited to 'lib/git/branches.rb') diff --git a/lib/git/branches.rb b/lib/git/branches.rb index d664d59..81abe22 100644 --- a/lib/git/branches.rb +++ b/lib/git/branches.rb @@ -8,8 +8,36 @@ module Git @branches = nil def initialize(base) + @branches = {} + @base = base - @branches = @base.lib.branches_all + @base.lib.branches_all.each do |b| + @branches[b.full] = b + end + end + + def local + self.select { |b| !b.remote } + end + + def remote + self.select { |b| b.remote } + end + + # array like methods + + def size + @branches.size + end + + def each + @branches.each do |k, b| + yield b + end + end + + def [](symbol) + @branches[symbol.to_s] end end -- cgit