class GitRecent::BranchLister
Attributes
local_branches[RW]
reflog_iterator[RW]
Public Class Methods
new(reflog_iterator=GitRecent::ReflogIterator.new, local_branches=GitRecent::LocalBranchReader.local_branches_excluding_current)
click to toggle source
# File lib/git_recent/branch_lister.rb, line 9 def initialize(reflog_iterator=GitRecent::ReflogIterator.new, local_branches=GitRecent::LocalBranchReader.local_branches_excluding_current) @reflog_iterator = reflog_iterator @local_branches = local_branches end
Public Instance Methods
branch_names(max)
click to toggle source
# File lib/git_recent/branch_lister.rb, line 15 def branch_names(max) recent_branches = {} reflog_iterator.each do |reflog_line| to_branch = reflog_line.to_branch recent_branches[to_branch] = true if should_include_branch? to_branch return recent_branches.keys if recent_branches.keys.length == max from_branch = reflog_line.from_branch recent_branches[from_branch] = true if should_include_branch? from_branch return recent_branches.keys if recent_branches.keys.length == max end recent_branches.keys end
Private Instance Methods
local_branch_exists?(checked_out_entity)
click to toggle source
# File lib/git_recent/branch_lister.rb, line 35 def local_branch_exists?(checked_out_entity) local_branches.include? checked_out_entity end
should_include_branch?(branch)
click to toggle source
# File lib/git_recent/branch_lister.rb, line 39 def should_include_branch?(branch) branch and local_branch_exists? branch end