summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarlhuda <carlhuda@engineyard.com>2010-02-01 12:53:35 -0800
committerCarlhuda <carlhuda@engineyard.com>2010-02-01 12:53:35 -0800
commite81a3d2b6a01d997a0a0581ad1b39c007d3b85c1 (patch)
tree754f3f8045d851fea2118c681e54fb107fb1a753
parentf4e7a03495c1fb2fd63c1cb06864318c9dccd024 (diff)
downloadbundler-e81a3d2b6a01d997a0a0581ad1b39c007d3b85c1.tar.gz
Fix a common problem where an outdated gem pushed to gemcutter was beating pinned git deps
-rw-r--r--bundler.gemspec2
-rw-r--r--lib/bundler/dsl.rb25
-rw-r--r--spec/install/git_spec.rb18
-rw-r--r--spec/install/path_spec.rb35
4 files changed, 60 insertions, 20 deletions
diff --git a/bundler.gemspec b/bundler.gemspec
index 55facc3944..05f5ccdaa4 100644
--- a/bundler.gemspec
+++ b/bundler.gemspec
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
s.default_executable = %q{bundle}
s.email = ["carlhuda@engineyard.com"]
s.executables = ["bundle"]
- s.files = ["bin/bundle", "lib/bundler/cli.rb", "lib/bundler/definition.rb", "lib/bundler/dependency.rb", "lib/bundler/dsl.rb", "lib/bundler/environment.rb", "lib/bundler/index.rb", "lib/bundler/installer.rb", "lib/bundler/remote_specification.rb", "lib/bundler/resolver.rb", "lib/bundler/rubygems.rb", "lib/bundler/setup.rb", "lib/bundler/source.rb", "lib/bundler/specification.rb", "lib/bundler/templates/environment.erb", "lib/bundler/templates/Gemfile", "lib/bundler/ui.rb", "lib/bundler/vendor/thor/actions/create_file.rb", "lib/bundler/vendor/thor/actions/directory.rb", "lib/bundler/vendor/thor/actions/empty_directory.rb", "lib/bundler/vendor/thor/actions/file_manipulation.rb", "lib/bundler/vendor/thor/actions/inject_into_file.rb", "lib/bundler/vendor/thor/actions.rb", "lib/bundler/vendor/thor/base.rb", "lib/bundler/vendor/thor/core_ext/file_binary_read.rb", "lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb", "lib/bundler/vendor/thor/core_ext/ordered_hash.rb", "lib/bundler/vendor/thor/error.rb", "lib/bundler/vendor/thor/group.rb", "lib/bundler/vendor/thor/invocation.rb", "lib/bundler/vendor/thor/parser/argument.rb", "lib/bundler/vendor/thor/parser/arguments.rb", "lib/bundler/vendor/thor/parser/option.rb", "lib/bundler/vendor/thor/parser/options.rb", "lib/bundler/vendor/thor/parser.rb", "lib/bundler/vendor/thor/rake_compat.rb", "lib/bundler/vendor/thor/runner.rb", "lib/bundler/vendor/thor/shell/basic.rb", "lib/bundler/vendor/thor/shell/color.rb", "lib/bundler/vendor/thor/shell.rb", "lib/bundler/vendor/thor/task.rb", "lib/bundler/vendor/thor/util.rb", "lib/bundler/vendor/thor/version.rb", "lib/bundler/vendor/thor.rb", "lib/bundler.rb", "LICENSE", "README.markdown"]
+ s.files = ["bin/bundle", "lib/bundler", "lib/bundler/cli.rb", "lib/bundler/definition.rb", "lib/bundler/dependency.rb", "lib/bundler/dsl.rb", "lib/bundler/environment.rb", "lib/bundler/index.rb", "lib/bundler/installer.rb", "lib/bundler/remote_specification.rb", "lib/bundler/resolver.rb", "lib/bundler/rubygems.rb", "lib/bundler/setup.rb", "lib/bundler/source.rb", "lib/bundler/specification.rb", "lib/bundler/templates", "lib/bundler/templates/environment.erb", "lib/bundler/templates/Gemfile", "lib/bundler/ui.rb", "lib/bundler/vendor", "lib/bundler/vendor/thor", "lib/bundler/vendor/thor/actions", "lib/bundler/vendor/thor/actions/create_file.rb", "lib/bundler/vendor/thor/actions/directory.rb", "lib/bundler/vendor/thor/actions/empty_directory.rb", "lib/bundler/vendor/thor/actions/file_manipulation.rb", "lib/bundler/vendor/thor/actions/inject_into_file.rb", "lib/bundler/vendor/thor/actions.rb", "lib/bundler/vendor/thor/base.rb", "lib/bundler/vendor/thor/core_ext", "lib/bundler/vendor/thor/core_ext/file_binary_read.rb", "lib/bundler/vendor/thor/core_ext/hash_with_indifferent_access.rb", "lib/bundler/vendor/thor/core_ext/ordered_hash.rb", "lib/bundler/vendor/thor/error.rb", "lib/bundler/vendor/thor/group.rb", "lib/bundler/vendor/thor/invocation.rb", "lib/bundler/vendor/thor/parser", "lib/bundler/vendor/thor/parser/argument.rb", "lib/bundler/vendor/thor/parser/arguments.rb", "lib/bundler/vendor/thor/parser/option.rb", "lib/bundler/vendor/thor/parser/options.rb", "lib/bundler/vendor/thor/parser.rb", "lib/bundler/vendor/thor/rake_compat.rb", "lib/bundler/vendor/thor/runner.rb", "lib/bundler/vendor/thor/shell", "lib/bundler/vendor/thor/shell/basic.rb", "lib/bundler/vendor/thor/shell/color.rb", "lib/bundler/vendor/thor/shell.rb", "lib/bundler/vendor/thor/task.rb", "lib/bundler/vendor/thor/util.rb", "lib/bundler/vendor/thor/version.rb", "lib/bundler/vendor/thor.rb", "lib/bundler.rb", "LICENSE", "README.markdown"]
s.homepage = %q{http://github.com/carlhuda/bundler}
s.require_paths = ["lib"]
s.rubygems_version = %q{1.3.5}
diff --git a/lib/bundler/dsl.rb b/lib/bundler/dsl.rb
index 90c17082b4..1727f12ce0 100644
--- a/lib/bundler/dsl.rb
+++ b/lib/bundler/dsl.rb
@@ -23,23 +23,23 @@ module Bundler
@dependencies << Dependency.new(name, version, options)
end
- def source(source)
+ def source(source, options = {})
source = case source
when :gemcutter, :rubygems, :rubyforge then Source::Rubygems.new(:uri => "http://gemcutter.org")
when String then Source::Rubygems.new(:uri => source)
else source
end
- @sources << source
+ options[:prepend] ? @sources.unshift(source) : @sources << source
source
end
def path(path, options = {})
- source Source::Path.new(options.merge(:path => path))
+ source Source::Path.new(options.merge(:path => path)), options
end
def git(uri, options = {})
- source Source::Git.new(options.merge(:uri => uri))
+ source Source::Git.new(options.merge(:uri => uri)), options
end
def to_definition
@@ -66,17 +66,14 @@ module Bundler
opts["group"] ||= @group
- _normalize_git_options(name, version, opts)
- end
-
- def _normalize_git_options(name, version, opts)
- # Normalize Git options
- if opts["git"]
- source = git(opts["git"], :ref => opts["ref"])
- source.default_spec name, version if _version?(version)
- opts["source"] = source
+ # Normalize git and path options
+ ["git", "path"].each do |type|
+ if param = opts[type]
+ source = send(type, param, opts.merge(:prepend => true))
+ source.default_spec name, version if _version?(version)
+ opts["source"] = source
+ end
end
end
-
end
end \ No newline at end of file
diff --git a/spec/install/git_spec.rb b/spec/install/git_spec.rb
index ce4e68a550..d1f1218eda 100644
--- a/spec/install/git_spec.rb
+++ b/spec/install/git_spec.rb
@@ -78,6 +78,24 @@ describe "gemfile install with git sources" do
should_be_installed "rack 0.8"
end
+
+ it "installs dependencies from git even if a newer gem is available elsewhere" do
+ build_lib "rack", "1.0", :path => lib_path('nested/bar') do |s|
+ s.write "lib/rack.rb", "puts 'WIN OVERRIDE'"
+ end
+
+ build_git "foo", :path => lib_path('nested') do |s|
+ s.add_dependency "rack", "= 1.0"
+ end
+
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "foo", :git => "#{lib_path('nested')}"
+ G
+
+ run "require 'rack'"
+ out.should == 'WIN OVERRIDE'
+ end
end
it "uses a ref if specified" do
diff --git a/spec/install/path_spec.rb b/spec/install/path_spec.rb
index e4df4d5f59..52a85ce434 100644
--- a/spec/install/path_spec.rb
+++ b/spec/install/path_spec.rb
@@ -1,10 +1,6 @@
require File.expand_path('../../spec_helper', __FILE__)
describe "gemfile install with git sources" do
- before :each do
- in_app_root
- end
-
it "fetches gems" do
build_lib "foo"
@@ -12,7 +8,36 @@ describe "gemfile install with git sources" do
path "#{lib_path('foo-1.0')}"
gem 'foo'
G
-
+
should_be_installed("foo 1.0")
end
+
+ it "supports pinned paths" do
+ build_lib "foo"
+
+ install_gemfile <<-G
+ gem 'foo', :path => "#{lib_path('foo-1.0')}"
+ G
+
+ should_be_installed("foo 1.0")
+ end
+
+ it "installs dependencies from the path even if a newer gem is available elsewhere" do
+ build_lib "rack", "1.0", :path => lib_path('nested/bar') do |s|
+ s.write "lib/rack.rb", "puts 'WIN OVERRIDE'"
+ end
+
+ build_lib "foo", :path => lib_path('nested') do |s|
+ s.add_dependency "rack", "= 1.0"
+ end
+
+ install_gemfile <<-G
+ source "file://#{gem_repo1}"
+ gem "foo", :path => "#{lib_path('nested')}"
+ G
+
+ run "require 'rack'"
+ out.should == 'WIN OVERRIDE'
+ end
+
end \ No newline at end of file