Class: Kamal::Cli::Build::Clone

Inherits:
Object
  • Object
show all
Defined in:
lib/kamal/cli/build/clone.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(sshkit) ⇒ Clone

Returns a new instance of Clone.



7
8
9
# File 'lib/kamal/cli/build/clone.rb', line 7

def initialize(sshkit)
  @sshkit = sshkit
end

Instance Attribute Details

#sshkitObject (readonly)

Returns the value of attribute sshkit.



4
5
6
# File 'lib/kamal/cli/build/clone.rb', line 4

def sshkit
  @sshkit
end

Instance Method Details

#prepareObject



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/kamal/cli/build/clone.rb', line 11

def prepare
  begin
    clone_repo
  rescue SSHKit::Command::Failed => e
    if e.message =~ /already exists and is not an empty directory/
      reset
    else
      raise Kamal::Cli::Build::BuildError, "Failed to clone repo: #{e.message}"
    end
  end

  validate!
rescue Kamal::Cli::Build::BuildError => e
  error "Error preparing clone: #{e.message}, deleting and retrying..."

  FileUtils.rm_rf KAMAL.config.builder.clone_directory
  clone_repo
  validate!
end