6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
# File 'lib/git-copy.rb', line 6
def self.copy(src, dst)
uri = Addressable::URI.parse(dst)
dst = File.absolute_path(dst) unless uri.scheme
if uri.scheme || File.exist?(dst)
Dir.mktmpdir('git-copy-') do |dir|
unless `git clone --bare #{src} #{dir}`.to_i == 0
raise 'git clone faild'
end
unless `cd #{dir}; git push -f --mirror #{dst}`.to_i == 0
raise 'git push faild'
end
end
else
unless `git clone --bare #{src} #{dst}`.to_i == 0
raise 'git clone failed'
end
end
end
|