diff --git a/lib/git/base.rb b/lib/git/base.rb index 4e472abe..4eda49d4 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -25,10 +25,11 @@ def self.bare(git_dir, opts = {}) # :index_file # def self.clone(repository, name, opts = {}) - # run git-clone - self.new(Git::Lib.new.clone(repository, name, opts)) + # run git-clone + log = opts[:log] + new(Git::Lib.new(nil, log).clone(repository, name, opts).merge(log: log)) end - + # Returns (and initialize if needed) a Git::Config instance # # @return [Git::Config] the current config instance. diff --git a/tests/units/test_base.rb b/tests/units/test_base.rb index 08f651a4..ba1b9307 100644 --- a/tests/units/test_base.rb +++ b/tests/units/test_base.rb @@ -1,5 +1,7 @@ #!/usr/bin/env ruby +require 'stringio' + require File.dirname(__FILE__) + '/../test_helper' class TestBase < Test::Unit::TestCase @@ -8,6 +10,18 @@ def setup set_file_paths end + def test_clone + in_temp_dir do |_path| + # Tests that the given logger object is used during the cloning phase as + # well as passed to the Base class's initialize method. + + buffer = StringIO.new + Git.clone(@wdir, 'test_add', log: Logger.new(buffer)) + assert_match(/Cloning into 'test_add'/, buffer.string) # Comes from the Cloning Process + assert_match(/Starting Git/, buffer.string) # Comes from the Base's initialize method + end + end + def test_add in_temp_dir do |path| git = Git.clone(@wdir, 'test_add')