diff options
author | wycats <wycats@gmail.com> | 2010-07-01 01:38:33 -0700 |
---|---|---|
committer | wycats <wycats@gmail.com> | 2010-07-01 01:38:33 -0700 |
commit | b04d92374e804b0d346b818e08ce8f0226c5b0a0 (patch) | |
tree | a205b67d579d3c0c56c8ad146c6cc5d88fb7cb0b | |
parent | e38a088289f66cc93a0d6d3b4c5d369517b1fc88 (diff) | |
download | bundler-b04d92374e804b0d346b818e08ce8f0226c5b0a0.tar.gz |
By default, do not expand submodules
-rw-r--r-- | lib/bundler/dsl.rb | 2 | ||||
-rw-r--r-- | lib/bundler/lockfile_parser.rb | 14 | ||||
-rw-r--r-- | lib/bundler/source.rb | 18 | ||||
-rw-r--r-- | spec/install/git_spec.rb | 21 | ||||
-rw-r--r-- | spec/support/matchers.rb | 4 |
5 files changed, 44 insertions, 15 deletions
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 5e9123877e..c4ab1a691f 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -158,7 +158,7 @@ module Bundler def _normalize_options(name, version, opts) _normalize_hash(opts) - invalid_keys = opts.keys - %w(group git path name branch ref tag require) + invalid_keys = opts.keys - %w(group git path name branch ref tag require submodules) if invalid_keys.any? plural = invalid_keys.size > 1 message = "You passed #{invalid_keys.map{|k| ':'+k }.join(", ")} " diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index 15578040dc..fe9b009369 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -39,11 +39,17 @@ module Bundler @current_source = TYPES[@type].from_lock(@opts) @sources << @current_source when /^ ([a-z]+): (.*)$/i - if @opts[$1] - @opts[$1] = Array(@opts[$1]) - @opts[$1] << $2 + value = $2 + value = true if value == "true" + value = false if value == "false" + + key = $1 + + if @opts[key] + @opts[key] = Array(@opts[key]) + @opts[key] << value else - @opts[$1] = $2 + @opts[key] = value end else parse_spec(line) diff --git a/lib/bundler/source.rb b/lib/bundler/source.rb index ca2b19ef1e..df03f76a54 100644 --- a/lib/bundler/source.rb +++ b/lib/bundler/source.rb @@ -446,10 +446,11 @@ module Bundler def initialize(options) super - @uri = options["uri"] - @ref = options["ref"] || options["branch"] || options["tag"] || 'master' - @revision = options["revision"] - @update = false + @uri = options["uri"] + @ref = options["ref"] || options["branch"] || options["tag"] || 'master' + @revision = options["revision"] + @submodules = options["submodules"] + @update = false end def self.from_lock(options) @@ -460,7 +461,7 @@ module Bundler out = "GIT\n" out << " remote: #{@uri}\n" out << " revision: #{shortref_for(revision)}\n" - %w(ref branch tag).each do |opt| + %w(ref branch tag submodules).each do |opt| out << " #{opt}: #{options[opt]}\n" if options[opt] end out << " glob: #{@glob}\n" unless @glob == DEFAULT_GLOB @@ -580,8 +581,11 @@ module Bundler Dir.chdir(path) do git "fetch --force --quiet" git "reset --hard #{revision}" - git "submodule init" - git "submodule update" + + if @submodules + git "submodule init" + git "submodule update" + end end end diff --git a/spec/install/git_spec.rb b/spec/install/git_spec.rb index 9b0089a5dd..ca67dd59d7 100644 --- a/spec/install/git_spec.rb +++ b/spec/install/git_spec.rb @@ -284,6 +284,25 @@ describe "bundle install with git sources" do should_be_installed "forced 1.0" end + it "ignores submodules if :submodule is not passed" do + build_git "submodule", "1.0" + build_git "has_submodule", "1.0" do |s| + s.add_dependency "submodule" + end + Dir.chdir(lib_path('has_submodule-1.0')) do + `git submodule add #{lib_path('submodule-1.0')} submodule-1.0` + `git commit -m "submodulator"` + end + + install_gemfile <<-G, :expect_err => true + git "#{lib_path('has_submodule-1.0')}" + gem "has_submodule" + G + + should_not_be_installed "has_submodule 1.0", :expect_err => true + err.should =~ /Could not find gem 'submodule'/ + end + it "handles repos with submodules" do build_git "submodule", "1.0" build_git "has_submodule", "1.0" do |s| @@ -295,7 +314,7 @@ describe "bundle install with git sources" do end install_gemfile <<-G - git "#{lib_path('has_submodule-1.0')}" + git "#{lib_path('has_submodule-1.0')}", :submodules => true gem "has_submodule" G diff --git a/spec/support/matchers.rb b/spec/support/matchers.rb index ab2e74e1db..19c9b0f197 100644 --- a/spec/support/matchers.rb +++ b/spec/support/matchers.rb @@ -43,10 +43,10 @@ module Spec def should_not_be_installed(*names) opts = names.last.is_a?(Hash) ? names.pop : {} - groups = opts[:groups] || [] + groups = Array(opts[:groups]) || [] names.each do |name| name, version = name.split(/\s+/) - run <<-R, *groups + run <<-R, *(groups + [opts]) begin require '#{name}' puts #{Spec::Builders.constantize(name)} |