Class: SmartBox::Modes::GitWorktreeMode

Inherits:
Object
  • Object
show all
Defined in:
lib/smart_box/modes/git_worktree_mode.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(source_path:, workspace_path:, box_id:) ⇒ GitWorktreeMode

Returns a new instance of GitWorktreeMode.



8
9
10
11
12
13
# File 'lib/smart_box/modes/git_worktree_mode.rb', line 8

def initialize(source_path:, workspace_path:, box_id:)
  @source_path    = File.expand_path(source_path)
  @workspace_path = File.expand_path(workspace_path)
  @box_id         = box_id
  @branch_name    = "smart-box/#{box_id}"
end

Instance Attribute Details

#branch_nameObject (readonly)

Returns the value of attribute branch_name.



6
7
8
# File 'lib/smart_box/modes/git_worktree_mode.rb', line 6

def branch_name
  @branch_name
end

#source_pathObject (readonly)

Returns the value of attribute source_path.



6
7
8
# File 'lib/smart_box/modes/git_worktree_mode.rb', line 6

def source_path
  @source_path
end

#workspace_pathObject (readonly)

Returns the value of attribute workspace_path.



6
7
8
# File 'lib/smart_box/modes/git_worktree_mode.rb', line 6

def workspace_path
  @workspace_path
end

Instance Method Details

#setupObject

— entry points —



17
18
19
20
21
22
# File 'lib/smart_box/modes/git_worktree_mode.rb', line 17

def setup
  validate_source!
  ensure_branch!
  create_worktree!
  init_checkpoint!
end

#teardownObject



24
25
26
# File 'lib/smart_box/modes/git_worktree_mode.rb', line 24

def teardown
  remove_worktree! if worktree_exists?
end