Class: Branchtree::Commands::Show
- Defined in:
- lib/branchtree/commands/show.rb
Instance Method Summary collapse
Methods inherited from Common
#load_situation, #load_tree, #pluralize
Methods included from Branchtree::Context
Instance Method Details
#execute ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/branchtree/commands/show.rb', line 11 def execute super situation = load_situation tree = load_tree current_branch = tree.find_branch(situation.current_branch_name) tree.depth_first do |level, branch| logger.debug "Loading branch #{branch.name}." branch.info.populate end tree.depth_first do |level, branch| line = "" if branch == current_branch line << "==> " else line << " " end line << " " * level line << branch.name if !branch.info.valid? line << " (branch missing)" else if branch.info.behind_parent > 0 line << " - #{pluralize(branch.info.behind_parent, "commit")} behind parent" end if branch.info.ahead_of_upstream > 0 if branch.info.behind_upstream > 0 line << " - diverged from upstream (#{branch.info.ahead_of_upstream}/#{branch.info.behind_upstream})" else line << " - #{pluralize(branch.info.ahead_of_upstream, "unpushed commit")}" end elsif branch.info.behind_upstream > 0 line << " - #{pluralize(branch.info.behind_upstream, "commit")} behind upstream" end end puts line end end |