class Imagen::Clone

Responsible for cloning a Git repository into a given tempdir

Attributes

dir[R]
repo_url[R]

Public Class Methods

new(repo_url, dirname) click to toggle source
# File lib/imagen/clone.rb, line 17
def initialize(repo_url, dirname)
  unless repo_url.match?(/^https:\/\//)
    raise ArgumentError, 'repo_url must start with https://'
  end

  @repo_url = repo_url
  @dir = dirname
end
perform(repo_url, dir) click to toggle source
# File lib/imagen/clone.rb, line 11
def self.perform(repo_url, dir)
  new(repo_url, dir).perform
end

Public Instance Methods

perform() click to toggle source
# File lib/imagen/clone.rb, line 26
def perform
  cmd = "GIT_TERMINAL_PROMPT=0 git clone #{repo_url} #{dir}"
  Open3.popen3(cmd) do |_s_in, _s_out, s_err, wait_thr|
    err_msg = s_err.read
    raise GitError, err_msg unless wait_thr.value.exitstatus.zero?
  end
end