summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Moore <tmoore@incrementalism.net>2015-02-27 13:10:07 +1100
committerTim Moore <tmoore@incrementalism.net>2015-02-27 13:10:07 +1100
commitd8f61693cc89476c1ee3cc01ccf03c0908531a4d (patch)
tree0f1a508a6baf466ab0544f68adf4d0d8a651ea8d
parent516d54839f202737dbb1b5e4cbe68198ac3715e9 (diff)
parented8182e4d460e0e7e6206817404f40e63552c85d (diff)
downloadbundler-d8f61693cc89476c1ee3cc01ccf03c0908531a4d.tar.gz
Merge pull request #3428 from segiddins/seg-path-depth-sort
[Source::Path] Sort gemspecs by relative depth
-rw-r--r--lib/bundler/source/path.rb3
-rw-r--r--spec/install/gemfile/path_spec.rb19
2 files changed, 21 insertions, 1 deletions
diff --git a/lib/bundler/source/path.rb b/lib/bundler/source/path.rb
index 59131a52b4..2b53bc7831 100644
--- a/lib/bundler/source/path.rb
+++ b/lib/bundler/source/path.rb
@@ -130,7 +130,8 @@ module Bundler
index = Index.new
if File.directory?(expanded_path)
- Dir["#{expanded_path}/#{@glob}"].each do |file|
+ # We sort depth-first since `<<` will override the earlier-found specs
+ Dir["#{expanded_path}/#{@glob}"].sort_by { |p| -p.split(File::SEPARATOR).size }.each do |file|
spec = Bundler.load_gemspec(file)
if spec
spec.loaded_from = file.to_s
diff --git a/spec/install/gemfile/path_spec.rb b/spec/install/gemfile/path_spec.rb
index 07449201c2..6ba4096457 100644
--- a/spec/install/gemfile/path_spec.rb
+++ b/spec/install/gemfile/path_spec.rb
@@ -120,6 +120,25 @@ describe "bundle install with explicit source paths" do
should_be_installed "foo 1.0"
end
+ it "prefers gemspecs closer to the path root" do
+ build_lib "premailer", "1.0.0", :path => lib_path("premailer") do |s|
+ s.write "gemfiles/ruby187.gemspec", <<-G
+ Gem::Specification.new do |s|
+ s.name = 'premailer'
+ s.version = '1.0.0'
+ end
+ G
+ end
+
+ install_gemfile <<-G
+ gem "premailer", :path => "#{lib_path("premailer")}"
+ G
+
+ # Installation of the 'gemfiles' gemspec would fail since it will be unable
+ # to require 'premailer.rb'
+ should_be_installed "premailer 1.0.0"
+ end
+
it "supports gemspec syntax" do
build_lib "foo", "1.0", :path => lib_path("foo") do |s|
s.add_dependency "rack", "1.0"