Method: RightGit::Git::BranchCollection#initialize
- Defined in:
- lib/right_git/git/branch_collection.rb
#initialize(repo, branches = nil) ⇒ BranchCollection
Create a new BranchCollection. Don’t pass in a branches parameter unless you really know what you’re doing; it’s intended more for internal use than anything else.
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
# File 'lib/right_git/git/branch_collection.rb', line 53 def initialize(repo, branches=nil) @repo = repo if branches # Use an arbitrary set of branches that was passed in @branches = branches else @branches = [] # Initialize ourselves with all branches in the repository git_args = ['branch', '-a'] @repo.git_output(git_args).lines.each do |line| line.strip! if line =~ NOT_A_BRANCH #no-op; ignore this one else @branches << Branch.new(@repo, line) end end end end |