From f9944f41f99afffdaba24ba70ee1fedda5b9aa0c Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Sun, 29 Aug 2010 16:09:43 +0900 Subject: [PATCH] Sanely add the "fake" version to the git source when the requirement is prefixed w/ equals --- lib/bundler/dsl.rb | 10 +++++----- lib/bundler/lockfile_parser.rb | 2 +- spec/install/git_spec.rb | 17 +++++++++++++++++ 3 files changed, 23 insertions(+), 6 deletions(-) diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb index 80bbf12d235..4e0a3fe307f 100644 --- a/lib/bundler/dsl.rb +++ b/lib/bundler/dsl.rb @@ -173,10 +173,6 @@ def rubygems_source(source) @sources << @rubygems_source end - def _version?(version) - version && Gem::Version.new(version) rescue false - end - def _normalize_hash(opts) # Cannot modify a hash during an iteration in 1.9 opts.keys.each do |k| @@ -218,7 +214,11 @@ def _normalize_options(name, version, opts) # Normalize git and path options ["git", "path"].each do |type| if param = opts[type] - options = _version?(version.first) ? opts.merge("name" => name, "version" => version.first) : opts.dup + if version.first && version.first =~ /^\s*=?\s*(\d[^\s]*)\s*$/ + options = opts.merge("name" => name, "version" => $1) + else + options = opts.dup + end source = send(type, param, options, :prepend => true) {} opts["source"] = source end diff --git a/lib/bundler/lockfile_parser.rb b/lib/bundler/lockfile_parser.rb index ce6377d9c76..10f8cbf2f4f 100644 --- a/lib/bundler/lockfile_parser.rb +++ b/lib/bundler/lockfile_parser.rb @@ -73,7 +73,7 @@ def parse_dependency(line) # to use in the case that there are no gemspecs present. A fake # gemspec is created based on the version set on the dependency # TODO: Use the version from the spec instead of from the dependency - if version && version.size == 1 && version.first =~ /^= (.+)$/ && dep.source.is_a?(Bundler::Source::Path) + if version && version.size == 1 && version.first =~ /^\s*= (.+)\s*$/ && dep.source.is_a?(Bundler::Source::Path) dep.source.name = name dep.source.version = $1 end diff --git a/spec/install/git_spec.rb b/spec/install/git_spec.rb index c4ef6d6430c..4cca0c83171 100644 --- a/spec/install/git_spec.rb +++ b/spec/install/git_spec.rb @@ -532,4 +532,21 @@ out.should == old_revision end end + + describe "bundle install --deployment with git sources" do + it "works" do + build_git "valim", :path => lib_path('valim') + + install_gemfile <<-G + source "file://#{gem_repo1}" + + gem "valim", "= 1.0", :git => "#{lib_path('valim')}" + G + + simulate_new_machine + + bundle "install --deployment", :exit_status => true + exitstatus.should == 0 + end + end end