class Branchtree::Branch::NullInfo
Public Class Methods
new(branch)
click to toggle source
# File lib/branchtree/branch.rb, line 68 def initialize(branch) @branch = branch end
Public Instance Methods
ahead_of_parent()
click to toggle source
# File lib/branchtree/branch.rb, line 80 def ahead_of_parent 0 end
ahead_of_upstream()
click to toggle source
# File lib/branchtree/branch.rb, line 92 def ahead_of_upstream 0 end
behind_parent()
click to toggle source
# File lib/branchtree/branch.rb, line 84 def behind_parent 0 end
behind_upstream()
click to toggle source
# File lib/branchtree/branch.rb, line 96 def behind_upstream 0 end
empty?()
click to toggle source
# File lib/branchtree/branch.rb, line 72 def empty? true end
has_upstream?()
click to toggle source
# File lib/branchtree/branch.rb, line 88 def has_upstream? false end
populate()
click to toggle source
# File lib/branchtree/branch.rb, line 100 def populate # Are we valid? valid_result = @branch.cmd.run!("git", "rev-parse", "--verify", "--quiet", @branch.full_ref) unless valid_result.success? return @branch.info = InvalidInfo.new(@branch) end parent_behind, parent_ahead = 0, 0 if @branch.parent && @branch.parent.info.valid? # Count ahead-behind from parent ahead_behind_parent = @branch.cmd.run( "git", "rev-list", "--left-right", "--count", "refs/heads/#{@branch.parent_branch_name}...#{@branch.full_ref}", ).out.chomp parent_behind, parent_ahead = ahead_behind_parent.split(/\t/, 2).map(&:to_i) end # Idenfity if we have an upstream upstream_ref, upstream_behind, upstream_ahead = "", 0, 0 upstream_result = @branch.cmd.run!( "git", "rev-parse", "--symbolic-full-name", "#{@branch.name}@{u}", ) if upstream_result.success? upstream_ref = upstream_result.out.chomp ahead_behind_upstream = @branch.cmd.run( "git", "rev-list", "--left-right", "--count", "#{upstream_ref}...#{@branch.full_ref}", ).out.chomp upstream_behind, upstream_ahead = ahead_behind_upstream.split(/\t/, 2).map(&:to_i) end @branch.info = Info.new( branch: @branch, ahead_of_parent: parent_ahead, behind_parent: parent_behind, upstream: upstream_ref, ahead_of_upstream: upstream_ahead, behind_upstream: upstream_behind, ) end
repopulate()
click to toggle source
# File lib/branchtree/branch.rb, line 140 def repopulate populate end
valid?()
click to toggle source
# File lib/branchtree/branch.rb, line 76 def valid? true end