Reputation: 620
How can I use ruby-git to recursively clone a remote repo?
I use this code:
require "git"
Git.clone "git://github.com/user/repo.git", "/tmp/repo"
but this does not recursively clone the repo from GitHub.
I need an analog for:
$ git clone git://github.com/user/repo.git /tmp/repo --recursive
Upvotes: 2
Views: 2049
Reputation: 160551
Sometimes the simplest path is to let the app do it itself. Why not use?
`git clone git://github.com/user/repo.git /tmp/repo --recursive`
Upvotes: 1
Reputation: 3267
Implementation of the #clone
method in ruby-git tells us that it is currently impossible:
https://github.com/schacon/ruby-git/blob/master/lib/git/lib.rb#L44
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 << "-o" << opts[:remote] if opts[:remote]
arr_opts << "--depth" << opts[:depth].to_i if opts[:depth] && opts[:depth].to_i > 0
arr_opts << '--'
arr_opts << repository
arr_opts << clone_dir
command('clone', arr_opts)
opts[:bare] ? {:repository => clone_dir} : {:working_directory => clone_dir}
end
You better fork ruby-git and insert a couple of lines there. It will solve your problem and the world will say "thank you".
Upvotes: 4