Class: RubyGit::Status::Branch

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby_git/status/branch.rb

Overview

Represents git branch information

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#aheadInteger

Number of commits ahead of upstream

Examples:

branch.ahead #=> 2


55
56
57
# File 'lib/ruby_git/status/branch.rb', line 55

def ahead
  @ahead
end

#behindInteger

Number of commits behind upstream

Examples:

branch.behind #=> 3


67
68
69
# File 'lib/ruby_git/status/branch.rb', line 67

def behind
  @behind
end

#nameString?

The name of the current branch

Examples:

branch.name #=> 'main'


19
20
21
# File 'lib/ruby_git/status/branch.rb', line 19

def name
  @name
end

#oidString

The object ID (hash) of the current commit

Examples:

branch.oid #=> 'abcdef1234567890'


31
32
33
# File 'lib/ruby_git/status/branch.rb', line 31

def oid
  @oid
end

#upstreamString?

The name of the upstream branch

Examples:

branch.upstream #=> 'origin/main'


43
44
45
# File 'lib/ruby_git/status/branch.rb', line 43

def upstream
  @upstream
end

Instance Method Details

#detached?Boolean

Check if HEAD is detached

Examples:

branch.detached? #=> true


87
88
89
# File 'lib/ruby_git/status/branch.rb', line 87

def detached?
  @name.nil?
end

#upstream?Boolean

Check if the branch has an upstream configured

Examples:

branch.upstream? #=> true


76
77
78
# File 'lib/ruby_git/status/branch.rb', line 76

def upstream?
  !@upstream.nil?
end