Signed-off-by: Li Yuanchao lyc163mail@163.com --- lib/git_mirror.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
diff --git a/lib/git_mirror.rb b/lib/git_mirror.rb index 99534f6..29d1390 100644 --- a/lib/git_mirror.rb +++ b/lib/git_mirror.rb @@ -31,12 +31,18 @@ class GitMirror @feedback_queue.push(@feedback_info) end
- def git_clone(url, mirror_dir) - ret = false - url = Array(url)[0] + def get_url(url) if url.include?('gitee.com/') && File.exist?("/srv/git/#{url.delete_prefix('https://%27)%7D") url = "/srv/git/#{url.delete_prefix('https://%27)%7D" + elsif url.include?('://github.com') + url = "https://gitclone.com/#%7Burl.split(%27://%27)%5B1%5D%7D" end + return url + end + + def git_clone(url, mirror_dir) + ret = false + url = get_url(Array(url)[0]) 10.times do stderr = %x(git clone --mirror #{url} #{mirror_dir} 2>&1) ret = !stderr.include?('fatal')