Class: Carson::Branch
- Inherits:
-
Object
- Object
- Carson::Branch
- Defined in:
- lib/carson/branch.rb
Instance Attribute Summary collapse
-
#delivery ⇒ Object
readonly
Returns the value of attribute delivery.
-
#head ⇒ Object
readonly
Returns the value of attribute head.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#purpose ⇒ Object
readonly
Returns the value of attribute purpose.
-
#repository ⇒ Object
readonly
Returns the value of attribute repository.
-
#worktree ⇒ Object
readonly
Returns the value of attribute worktree.
Instance Method Summary collapse
-
#initialize(repository:, name:, runtime:, purpose: nil, head: nil, worktree: nil, delivery: nil) ⇒ Branch
constructor
A new instance of Branch.
-
#reload ⇒ Object
Re-reads the branch facts from git and Carson’s ledger.
Constructor Details
#initialize(repository:, name:, runtime:, purpose: nil, head: nil, worktree: nil, delivery: nil) ⇒ Branch
Returns a new instance of Branch.
6 7 8 9 10 11 12 13 14 |
# File 'lib/carson/branch.rb', line 6 def initialize( repository:, name:, runtime:, purpose: nil, head: nil, worktree: nil, delivery: nil ) @repository = repository @name = name @runtime = runtime @purpose = purpose @head = head @worktree = worktree @delivery = delivery end |
Instance Attribute Details
#delivery ⇒ Object (readonly)
Returns the value of attribute delivery.
4 5 6 |
# File 'lib/carson/branch.rb', line 4 def delivery @delivery end |
#head ⇒ Object (readonly)
Returns the value of attribute head.
4 5 6 |
# File 'lib/carson/branch.rb', line 4 def head @head end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/carson/branch.rb', line 4 def name @name end |
#purpose ⇒ Object (readonly)
Returns the value of attribute purpose.
4 5 6 |
# File 'lib/carson/branch.rb', line 4 def purpose @purpose end |
#repository ⇒ Object (readonly)
Returns the value of attribute repository.
4 5 6 |
# File 'lib/carson/branch.rb', line 4 def repository @repository end |
#worktree ⇒ Object (readonly)
Returns the value of attribute worktree.
4 5 6 |
# File 'lib/carson/branch.rb', line 4 def worktree @worktree end |
Instance Method Details
#reload ⇒ Object
Re-reads the branch facts from git and Carson’s ledger.
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
# File 'lib/carson/branch.rb', line 17 def reload refreshed_head = runtime.git_capture!( "rev-parse", name ).strip refreshed_worktree = runtime.worktree_list.find { |entry| entry.branch == name }&.path || worktree refreshed_delivery = runtime.ledger.active_delivery( repo_path: repository.path, branch_name: name ) self.class.new( repository: repository, name: name, runtime: runtime, purpose: purpose, head: refreshed_head, worktree: refreshed_worktree, delivery: refreshed_delivery ) rescue StandardError self end |