Class: LearnTest::Git::Wip::Branch
- Inherits:
-
Object
- Object
- LearnTest::Git::Wip::Branch
- Defined in:
- lib/learn_test/git/wip/branch.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#parent ⇒ Object
Returns the value of attribute parent.
Instance Method Summary collapse
-
#initialize(base:, name:) ⇒ Branch
constructor
A new instance of Branch.
- #last_revision(raise_no_commits: false) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(base:, name:) ⇒ Branch
Returns a new instance of Branch.
9 10 11 12 |
# File 'lib/learn_test/git/wip/branch.rb', line 9 def initialize(base:, name:) @base = base @name = name end |
Instance Attribute Details
#parent ⇒ Object
Returns the value of attribute parent.
7 8 9 |
# File 'lib/learn_test/git/wip/branch.rb', line 7 def parent @parent end |
Instance Method Details
#last_revision(raise_no_commits: false) ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/learn_test/git/wip/branch.rb', line 14 def last_revision(raise_no_commits: false) @last_revision ||= begin begin @base.revparse(@name) rescue ::Git::GitExecuteError => e regex = Errors::NoCommitsError::REGEX if raise_no_commits raise e..match(regex) ? Errors::NoCommitsError.new(@name) : e end raise unless e..match(regex) false end end end |
#to_s ⇒ Object
32 33 34 |
# File 'lib/learn_test/git/wip/branch.rb', line 32 def to_s @name end |