Class: Git::Worktree
- Inherits:
-
Object
- Object
- Git::Worktree
- Defined in:
- lib/git/worktree.rb
Overview
A worktree in a Git repository
Instance Attribute Summary collapse
Instance Method Summary collapse
- #add
- #gcommit
-
#initialize(base, dir, gcommit = nil) ⇒ Worktree
constructor
A new instance of Worktree.
- #remove
- #to_a
- #to_s
Constructor Details
#initialize(base, dir, gcommit = nil) ⇒ Worktree
Returns a new instance of Worktree.
10 11 12 13 14 15 16 |
# File 'lib/git/worktree.rb', line 10 def initialize(base, dir, gcommit = nil) @full = dir @full += " #{gcommit}" unless gcommit.nil? @base = base @dir = dir @gcommit = gcommit end |
Instance Attribute Details
#dir
Returns the value of attribute dir.
8 9 10 |
# File 'lib/git/worktree.rb', line 8 def dir @dir end |
#full
Returns the value of attribute full.
8 9 10 |
# File 'lib/git/worktree.rb', line 8 def full @full end |
Instance Method Details
#add
23 24 25 |
# File 'lib/git/worktree.rb', line 23 def add @base.lib.worktree_add(@dir, @gcommit) end |
#gcommit
18 19 20 21 |
# File 'lib/git/worktree.rb', line 18 def gcommit @gcommit ||= @base.gcommit(@full) @gcommit end |
#remove
27 28 29 |
# File 'lib/git/worktree.rb', line 27 def remove @base.lib.worktree_remove(@dir) end |
#to_a
31 32 33 |
# File 'lib/git/worktree.rb', line 31 def to_a [@full] end |
#to_s
35 36 37 |
# File 'lib/git/worktree.rb', line 35 def to_s @full end |