Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
added ability to pass in options to the branch class
added unit-test to gemfile
  • Loading branch information
david.rooks@gmail.com committed Jan 13, 2016
commit 30ff9c827c00988d3c5294df5ecf89a53e86d5ec
2 changes: 2 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ source 'https://rubygems.org'

gemspec :name => 'git'

gem 'test-unit'

4 changes: 2 additions & 2 deletions lib/git/base/factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {})
Expand Down
4 changes: 2 additions & 2 deletions lib/git/branches.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions lib/git/lib.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down