Skip to content
This repository has been archived by the owner on Apr 14, 2021. It is now read-only.

Commit

Permalink
Auto merge of #5090 - bundler:aa-missing-specs, r=indirect
Browse files Browse the repository at this point in the history
[Index] Allow pre-release versions in search when the base is pre-release

Closes #5089
  • Loading branch information
homu authored and segiddins committed Oct 15, 2016
1 parent a7834e4 commit 8dc0010
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 5 deletions.
3 changes: 2 additions & 1 deletion lib/bundler/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,8 @@ def search_by_dependency(dependency, base = nil)
end

wants_prerelease = dependency.requirement.prerelease?
only_prerelease = specs.all? {|spec| spec.version.prerelease? }
wants_prerelease ||= base && base.any? {|base_spec| base_spec.version.prerelease? }
only_prerelease = specs.all? {|spec| spec.version.prerelease? }

unless wants_prerelease || only_prerelease
found.reject! {|spec| spec.version.prerelease? }
Expand Down
66 changes: 66 additions & 0 deletions spec/install/gemfile/sources_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -449,4 +449,70 @@
end
end
end

context "when a gem is installed to system gems" do
before do
install_gemfile! <<-G
source "file://#{gem_repo1}"
gem "rack"
G
end

context "and the gemfile changes" do
it "is still able to find that gem from remote sources" do
source_uri = "file://#{gem_repo1}"
second_uri = "file://#{gem_repo4}"

build_repo4 do
build_gem "rack", "2.0.1.1.forked"
build_gem "thor", "0.19.1.1.forked"
end

# When this gemfile is installed...
gemfile <<-G
source "#{source_uri}"
source "#{second_uri}" do
gem "rack", "2.0.1.1.forked"
gem "thor"
end
gem "rack-obama"
G

# It creates this lockfile.
lockfile <<-L
GEM
remote: #{source_uri}/
remote: #{second_uri}/
specs:
rack (2.0.1.1.forked)
rack-obama (1.0)
rack
thor (0.19.1.1.forked)
PLATFORMS
ruby
DEPENDENCIES
rack (= 2.0.1.1.forked)!
rack-obama
thor!
L

# Then we change the Gemfile by adding a version to thor
gemfile <<-G
source "#{source_uri}"
source "#{second_uri}" do
gem "rack", "2.0.1.1.forked"
gem "thor", "0.19.1.1.forked"
end
gem "rack-obama"
G

# But we should still be able to find rack 2.0.1.1.forked and install it
bundle! :install
end
end
end
end
8 changes: 5 additions & 3 deletions spec/support/artifice/compact_index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,11 @@ def gems(gem_repo = GEM_REPO)
@gems ||= {}
@gems[gem_repo] ||= begin
specs = Bundler::Deprecate.skip_during do
Marshal.load(File.open(gem_repo.join("specs.4.8")).read).map do |name, version, platform|
load_spec(name, version, platform, gem_repo)
end
%w(specs.4.8 prerelease_specs.4.8).map do |filename|
Marshal.load(File.open(gem_repo.join(filename)).read).map do |name, version, platform|
load_spec(name, version, platform, gem_repo)
end
end.flatten
end

specs.group_by(&:name).map do |name, versions|
Expand Down
6 changes: 5 additions & 1 deletion spec/support/artifice/endpoint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@ def dependencies_for(gem_names, gem_repo = GEM_REPO)
require "rubygems"
require "bundler"
Bundler::Deprecate.skip_during do
Marshal.load(File.open(gem_repo.join("specs.4.8")).read).map do |name, version, platform|
all_specs = %w(specs.4.8 prerelease_specs.4.8).map do |filename|
Marshal.load(File.open(gem_repo.join(filename)).read)
end.inject(:+)

all_specs.map do |name, version, platform|
spec = load_spec(name, version, platform, gem_repo)
next unless gem_names.include?(spec.name)
{
Expand Down

0 comments on commit 8dc0010

Please sign in to comment.