Class: Worktree::Command::Open

Inherits:
Object
  • Object
show all
Defined in:
lib/worktree/command/open.rb

Instance Method Summary collapse

Constructor Details

#initialize(branch, project_dir:) ⇒ Open

Returns a new instance of Open.



8
9
10
11
12
# File 'lib/worktree/command/open.rb', line 8

def initialize(branch, project_dir:)
  @branch = branch
  @project_dir = project_dir || Project.resolve(branch).root
  @worktree = "#{@project_dir}/#{@branch}"
end

Instance Method Details

#do!Object



14
15
16
17
18
19
# File 'lib/worktree/command/open.rb', line 14

def do!
  raise "Worktree #{@worktree} not found exists!" unless Dir.exist?(@worktree)
  raise 'No master repo found!' unless Dir.exist?("#{@project_dir}/master/.git")

  tmux
end