Method: Daddy::Git#previous_branch
- Defined in:
- lib/daddy/git.rb
#previous_branch(remote = false) ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/daddy/git.rb', line 40 def previous_branch(remote = false) current_branch = self.current_branch branches = self.branches(remote) branches.each_with_index do |b, i| return nil if i == branches.size - 1 if b == current_branch or b == "remotes/origin/#{current_branch}" return branches[i+1] end end end |