diff --git a/Gemfile b/Gemfile index 7054c552..ed16ab13 100644 --- a/Gemfile +++ b/Gemfile @@ -2,3 +2,5 @@ source 'https://rubygems.org' gemspec :name => 'git' +gem 'test-unit' + diff --git a/lib/git/base/factory.rb b/lib/git/base/factory.rb index b97bfab5..9dfb87b1 100644 --- a/lib/git/base/factory.rb +++ b/lib/git/base/factory.rb @@ -11,8 +11,8 @@ def branch(branch_name = 'master') # returns a Git::Branches object of all the Git::Branch # objects for this repo - def branches - Git::Branches.new(self) + def branches(opts=[]) + Git::Branches.new(self, opts) end def commit_tree(tree = nil, opts = {}) diff --git a/lib/git/branches.rb b/lib/git/branches.rb index fc871db8..c2b762cf 100644 --- a/lib/git/branches.rb +++ b/lib/git/branches.rb @@ -5,12 +5,12 @@ class Branches include Enumerable - def initialize(base) + def initialize(base, opts=[]) @branches = {} @base = base - @base.lib.branches_all.each do |b| + @base.lib.branches_all(opts).each do |b| @branches[b[0]] = Git::Branch.new(@base, b[0]) end end diff --git a/lib/git/lib.rb b/lib/git/lib.rb index a0c25de6..61758bcf 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -297,9 +297,9 @@ def change_head_branch(branch_name) command('symbolic-ref', ['HEAD', "refs/heads/#{branch_name}"]) end - def branches_all + def branches_all(opts=[]) arr = [] - command_lines('branch', '-a').each do |b| + command_lines('branch', opts.unshift('-a')).each do |b| current = (b[0, 2] == '* ') arr << [b.gsub('* ', '').strip, current] end