Method: Milkode::Cdstk#git_clone_in

Defined in:
lib/milkode/cdstk/cdstk.rb

#git_clone_in(url, options) ⇒ Object



294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/milkode/cdstk/cdstk.rb', line 294

def git_clone_in(url, options)
  dst_dir  = File.join(@db_dir, "packages/git")
  name     = options[:name] || File.basename(url).sub(/\.git\Z/, "")
  filename = File.join(dst_dir, name)

  unless File.exist?(filename)
    # git output progress to stderr.
    # `git clone #{url} #{filename} 2>&1`

    # with output
    if options[:branch_name]
      alert("git", "#{url} (#{options[:branch_name]})")
      system("git clone #{url} #{filename} -b #{options[:branch_name]}")
    else
      alert("git", url)
      system("git clone #{url} #{filename}")
    end
  end

  filename
end