16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
|
# File 'lib/msp_release/git.rb', line 16
def clone(git_url, options={})
out_to = options[:out_to]
exec_options = options[:exec] || {}
depth_arg = options[:depth].nil?? '' : "--depth #{options[:depth]}"
branch = options[:branch].nil?? '' : "--branch #{options[:branch]}"
heads = StringIO.new
MSPRelease::Exec.exec("git ls-remote --heads #{git_url}", :output => heads)
unless heads.string.match(/#{options[:branch]}/)
raise MSPRelease::CLI::Exit, "Git pathspec 'origin/#{options[:branch]}' does not exist"
end
single_branch = if version_gte(1, 7, 10)
options[:no_single_branch] ? '--no-single-branch' :
options[:single_branch] ? '--single-branch' :
''
end
MSPRelease::Exec.
exec("git clone #{depth_arg} #{single_branch} #{branch} #{git_url} #{out_to.nil?? '' : out_to}", exec_options)
end
|