class Git::Lib

def clone(repository, name, opts = {})


TODO - make this work with SSH password or auth_key

:recursive:: after the clone is created, initialize all submodules within, using their default settings.
:remote:: name of remote (rather than 'origin')
:path:: directory where the repo will be cloned
:origin:: name of remote (same as remote)
:depth:: the number of commits back to pull
:branch:: name of branch to track (rather than 'master')
:bare:: no working directory
accepts options:

{:working_directory} otherwise
returns {:repository} (if bare)

tries to clone the given repo
def clone(repository, name, opts = {})
  @path = opts[:path] || '.'
  clone_dir = opts[:path] ? File.join(@path, name) : name
  arr_opts = []
  arr_opts << '--bare' if opts[:bare]
  arr_opts << '--branch' << opts[:branch] if opts[:branch]
  arr_opts << '--depth' << opts[:depth].to_i if opts[:depth] && opts[:depth].to_i > 0
  arr_opts << '--config' << opts[:config] if opts[:config]
  arr_opts << '--origin' << opts[:remote] || opts[:origin] if opts[:remote] || opts[:origin]
  arr_opts << '--recursive' if opts[:recursive]
  arr_opts << "--mirror" if opts[:mirror]
  arr_opts << '--'
  arr_opts << repository
  arr_opts << clone_dir
  command('clone', arr_opts)
  (opts[:bare] or opts[:mirror]) ? {:repository => clone_dir} : {:working_directory => clone_dir}
end