Skip to content

Commit

Permalink
Sanely add the "fake" version to the git source when the requirement …
Browse files Browse the repository at this point in the history
…is prefixed w/ equals
  • Loading branch information
Carl Lerche committed Aug 29, 2010
1 parent 1fa55a3 commit f9944f4
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
10 changes: 5 additions & 5 deletions lib/bundler/dsl.rb
Expand Up @@ -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|
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/bundler/lockfile_parser.rb
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions spec/install/git_spec.rb
Expand Up @@ -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

0 comments on commit f9944f4

Please sign in to comment.