diff --git a/git.gemspec b/git.gemspec index 00e2b9f3..249dc3a7 100644 --- a/git.gemspec +++ b/git.gemspec @@ -5,12 +5,12 @@ Gem::Specification.new do |s| s.name = %q{git} - s.version = "1.2.5" + s.version = "1.2.5.1" s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version= - s.authors = ["Scott Chacon"] - s.date = %q{2009-10-17} - s.email = %q{schacon@gmail.com} + s.authors = ["Joe Yang"] + s.date = %q{2009-10-21} + s.email = %q{joe.yangyi@gmail.com} s.extra_rdoc_files = [ "README" ] @@ -33,7 +33,7 @@ Gem::Specification.new do |s| "lib/git/status.rb", "lib/git/working_directory.rb" ] - s.homepage = %q{http://github.com/schacon/ruby-git} + s.homepage = %q{http://github.com/yangyi/ruby-git} s.rdoc_options = ["--charset=UTF-8"] s.require_paths = ["lib"] s.requirements = ["git 1.6.0.0, or greater"] diff --git a/lib/git/base.rb b/lib/git/base.rb index 5ad8906a..891261cb 100644 --- a/lib/git/base.rb +++ b/lib/git/base.rb @@ -18,17 +18,19 @@ def self.open(working_dir, opts={}) # options: # :repository # :index_file + # :bare # def self.init(working_dir, opts = {}) opts = { :working_directory => working_dir, - :repository => File.join(working_dir, '.git') + :repository => opts[:bare] ? working_dir : File.join(working_dir, '.git') }.merge(opts) FileUtils.mkdir_p(opts[:working_directory]) if opts[:working_directory] && !File.directory?(opts[:working_directory]) + opts[:working_directory] = nil if opts[:bare] # not using working directory if it is bare # run git_init there - Git::Lib.new(opts).init + Git::Lib.new(opts).init(opts[:bare]) self.new(opts) end diff --git a/lib/git/lib.rb b/lib/git/lib.rb index 52fb2e6c..f417b1de 100644 --- a/lib/git/lib.rb +++ b/lib/git/lib.rb @@ -25,8 +25,8 @@ def initialize(base = nil, logger = nil) @logger = logger end - def init - command('init') + def init(bare = false) + command('init', bare ? "--bare" : []) end # tries to clone the given repo diff --git a/tests/units/test_init.rb b/tests/units/test_init.rb index c192dc07..e8e7d3cd 100644 --- a/tests/units/test_init.rb +++ b/tests/units/test_init.rb @@ -38,6 +38,14 @@ def test_git_init end end + def test_git_init_bare + in_temp_dir do |path| + Git.init(path, :bare => true) + assert(File.directory?(path)) + assert(File.exists?(File.join(path, "config"))) + end + end + def test_git_init_remote_git in_temp_dir do |dir| assert(!File.exists?(File.join(dir, 'config')))