From 401f2f06632048a502435b755728d41ca503672b Mon Sep 17 00:00:00 2001 From: Anthony Roy Date: Thu, 1 May 2014 12:54:29 +0100 Subject: [PATCH 1/3] Added mirror flag to clone options --- lib/git/lib.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/git/lib.rb b/lib/git/lib.rb index 975bc148..8d897411 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -61,6 +61,7 @@ def clone(repository, name, opts = {}) 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 << "--config" << opts[:config] if opts[:config] + arr_opts << "--mirror" << opts[:config] if opts[:config] arr_opts << '--' arr_opts << repository From e24d8b4e51e1c928264ae7bbeef803ba57a3e46a Mon Sep 17 00:00:00 2001 From: Anthony Roy Date: Thu, 1 May 2014 12:58:01 +0100 Subject: [PATCH 2/3] Updated vgem version --- lib/git/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/git/version.rb b/lib/git/version.rb index cc83c888..7b2b1b44 100644 --- a/lib/git/version.rb +++ b/lib/git/version.rb @@ -2,6 +2,6 @@ module Git # The current gem version # @return [String] the current gem version. - VERSION='1.2.6' + VERSION='1.2.7' end From 605a2f8885f61dff2c3a5b7e37e8fa984a330789 Mon Sep 17 00:00:00 2001 From: Anthony Roy Date: Thu, 1 May 2014 18:13:00 +0100 Subject: [PATCH 3/3] Added mirror option to clone. Added remote update for mirror repos. Added logging for clone --- lib/git/base.rb | 4 +++- lib/git/lib.rb | 16 +++++++++++++--- 2 files changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/git/base.rb b/lib/git/base.rb index bcec10e6..c2d5fc02 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -52,7 +52,9 @@ def self.init(working_dir, opts = {}) # def self.clone(repository, name, opts = {}) # run git-clone - self.new(Git::Lib.new.clone(repository, name, opts)) + logger = opts[:log] + + self.new(Git::Lib.new(nil, logger).clone(repository, name, opts)) end def initialize(options = {}) diff --git a/lib/git/lib.rb b/lib/git/lib.rb index 8d897411..1f5abce2 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -61,7 +61,7 @@ def clone(repository, name, opts = {}) 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 << "--config" << opts[:config] if opts[:config] - arr_opts << "--mirror" << opts[:config] if opts[:config] + arr_opts << "--mirror" if opts[:mirror] arr_opts << '--' arr_opts << repository @@ -69,7 +69,7 @@ def clone(repository, name, opts = {}) command('clone', arr_opts) - opts[:bare] ? {:repository => clone_dir} : {:working_directory => clone_dir} + (opts[:bare] or opts[:mirror]) ? {:repository => clone_dir} : {:working_directory => clone_dir} end @@ -227,7 +227,8 @@ def branches_all arr = [] command_lines('branch', '-a').each do |b| current = (b[0, 2] == '* ') - arr << [b.gsub('* ', '').strip, current] + branch = b.gsub('* ', '').strip + arr << [branch, current] unless branch == '(no branch)' end arr end @@ -577,6 +578,15 @@ def remote_remove(name) command('remote', ['rm', name]) end + def remote_update(opts={}) + remotes=opts.delete(:remotes) + arr_opts = ['update'] + arr_opts << '-p' if opts[:prune] + arr_opts.concat remotes if remotes + + command('remote', arr_opts) + end + def remotes command_lines('remote') end