Class: Worktree::Command::Init

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

Overview

:nodoc:

Instance Method Summary collapse

Constructor Details

#initialize(uri, name:, path:, remote: 'origin') ⇒ Init

Returns a new instance of Init.



6
7
8
9
10
11
# File 'lib/worktree/command/init.rb', line 6

def initialize(uri, name:, path:, remote: 'origin')
  @uri = uri
  @path = File.expand_path path
  @remote = remote
  @name = name || build_name
end

Instance Method Details

#do!Object



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

def do!
  FileUtils.mkdir_p "#{@path}/#{@name}"

  Dir.chdir "#{@path}/#{@name}" do
    @git = Git.clone(@uri, 'master', remote: @remote, log: Worktree.logger)
  end
end