Skip to content

Commit 605a2f8

Browse files
committed
Added mirror option to clone. Added remote update for mirror repos. Added logging for clone
1 parent e24d8b4 commit 605a2f8

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

lib/git/base.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ def self.init(working_dir, opts = {})
5252
#
5353
def self.clone(repository, name, opts = {})
5454
# run git-clone
55-
self.new(Git::Lib.new.clone(repository, name, opts))
55+
logger = opts[:log]
56+
57+
self.new(Git::Lib.new(nil, logger).clone(repository, name, opts))
5658
end
5759

5860
def initialize(options = {})

lib/git/lib.rb

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,15 @@ def clone(repository, name, opts = {})
6161
arr_opts << "-o" << opts[:remote] if opts[:remote]
6262
arr_opts << "--depth" << opts[:depth].to_i if opts[:depth] && opts[:depth].to_i > 0
6363
arr_opts << "--config" << opts[:config] if opts[:config]
64-
arr_opts << "--mirror" << opts[:config] if opts[:config]
64+
arr_opts << "--mirror" if opts[:mirror]
6565

6666
arr_opts << '--'
6767
arr_opts << repository
6868
arr_opts << clone_dir
6969

7070
command('clone', arr_opts)
7171

72-
opts[:bare] ? {:repository => clone_dir} : {:working_directory => clone_dir}
72+
(opts[:bare] or opts[:mirror]) ? {:repository => clone_dir} : {:working_directory => clone_dir}
7373
end
7474

7575

@@ -227,7 +227,8 @@ def branches_all
227227
arr = []
228228
command_lines('branch', '-a').each do |b|
229229
current = (b[0, 2] == '* ')
230-
arr << [b.gsub('* ', '').strip, current]
230+
branch = b.gsub('* ', '').strip
231+
arr << [branch, current] unless branch == '(no branch)'
231232
end
232233
arr
233234
end
@@ -577,6 +578,15 @@ def remote_remove(name)
577578
command('remote', ['rm', name])
578579
end
579580

581+
def remote_update(opts={})
582+
remotes=opts.delete(:remotes)
583+
arr_opts = ['update']
584+
arr_opts << '-p' if opts[:prune]
585+
arr_opts.concat remotes if remotes
586+
587+
command('remote', arr_opts)
588+
end
589+
580590
def remotes
581591
command_lines('remote')
582592
end

0 commit comments

Comments
 (0)