bundler 1.0.5 → 1.0.7

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of bundler might be problematic. Click here for more details.

data/.gitignore CHANGED
@@ -17,3 +17,6 @@ lib/bundler/man
17
17
 
18
18
  # output from ci_reporter
19
19
  spec/reports
20
+
21
+ # Netbeans
22
+ nbproject
@@ -1,3 +1,25 @@
1
+ ## 1.0.7 (November 17, 2010)
2
+
3
+ Bugfixes:
4
+
5
+ - Remove Bundler version from the lockfile because it broke
6
+ backwards compatibility with 1.0.0-1.0.5. Sorry. :(
7
+
8
+ ## 1.0.6 (November 16, 2010)
9
+
10
+ Bugfixes:
11
+
12
+ - Fix regression in `update` that caused long/wrong results
13
+ - Allow git gems on other platforms while installing (#579)
14
+
15
+ Features:
16
+
17
+ - Speed up `install` command using various optimizations
18
+ - Significantly increase performance of resolver
19
+ - Use upcoming Rubygems performance improvements (@tmm1)
20
+ - Warn if the lockfile was generated by a newer version
21
+ - Set generated gems' homepage to "", so Rubygems will warn
22
+
1
23
  ## 1.0.5 (November 13, 2010)
2
24
 
3
25
  Bugfixes:
data/Rakefile CHANGED
@@ -24,7 +24,7 @@ begin
24
24
  namespace :ci do
25
25
  desc "Run specs with Hudson output"
26
26
  RSpec::Core::RakeTask.new(:spec)
27
- task :spec => ["ci:setup:rspec", "man:build"]
27
+ task :spec => ["ci:setup:rspec", "man:build", "spec:set_sudo"]
28
28
  end
29
29
 
30
30
  rescue LoadError
data/bin/bundle CHANGED
@@ -15,7 +15,8 @@ rescue Bundler::BundlerError => e
15
15
  Bundler.ui.error e.message
16
16
  Bundler.ui.debug e.backtrace.join("\n")
17
17
  exit e.status_code
18
- rescue Interrupt
18
+ rescue Interrupt => e
19
19
  Bundler.ui.error "\nQuitting..."
20
+ Bundler.ui.debug e.backtrace.join("\n")
20
21
  exit 1
21
22
  end
@@ -148,9 +148,7 @@ module Bundler
148
148
  end
149
149
 
150
150
  # Run a resolve against the locally available gems
151
- local = Resolver.resolve(expanded_dependencies,
152
- index, source_requirements, last_resolve, unlocked?)
153
- last_resolve.merge(local)
151
+ last_resolve.merge Resolver.resolve(expanded_dependencies, index, source_requirements, last_resolve)
154
152
  end
155
153
  end
156
154
  end
@@ -342,7 +340,7 @@ module Bundler
342
340
 
343
341
  if in_locked_deps?(dep, locked_dep) || satisfies_locked_spec?(dep)
344
342
  deps << dep
345
- elsif dep.source.is_a?(Source::Path) && (!locked_dep || dep.source != locked_dep.source)
343
+ elsif dep.source.is_a?(Source::Path) && dep.current_platform? && (!locked_dep || dep.source != locked_dep.source)
346
344
  @locked_specs.each do |s|
347
345
  @unlock[:gems] << s.name if s.source == dep.source
348
346
  end
@@ -385,7 +383,7 @@ module Bundler
385
383
  next unless source.respond_to?(:unlock!)
386
384
 
387
385
  unless resolve.any? { |s| s.source == source }
388
- source.unlock! if diff.any? { |s| s.source == source }
386
+ source.unlock! if !diff.empty? && diff.any? { |s| s.source == source }
389
387
  end
390
388
  end
391
389
 
@@ -427,9 +425,5 @@ module Bundler
427
425
  groups.map! { |g| g.to_sym }
428
426
  dependencies.reject { |d| !d.should_include? || (d.groups & groups).empty? }
429
427
  end
430
-
431
- def unlocked?
432
- @lockfile_contents.empty?
433
- end
434
428
  end
435
429
  end
@@ -9,15 +9,17 @@ module Bundler
9
9
  attr_reader :platforms
10
10
 
11
11
  PLATFORM_MAP = {
12
- :ruby => Gem::Platform::RUBY,
13
- :ruby_18 => Gem::Platform::RUBY,
14
- :ruby_19 => Gem::Platform::RUBY,
15
- :mri => Gem::Platform::RUBY,
16
- :mri_18 => Gem::Platform::RUBY,
17
- :mri_19 => Gem::Platform::RUBY,
18
- :jruby => Gem::Platform::JAVA,
19
- :mswin => Gem::Platform::MSWIN,
20
- :mingw => Gem::Platform::MINGW
12
+ :ruby => Gem::Platform::RUBY,
13
+ :ruby_18 => Gem::Platform::RUBY,
14
+ :ruby_19 => Gem::Platform::RUBY,
15
+ :mri => Gem::Platform::RUBY,
16
+ :mri_18 => Gem::Platform::RUBY,
17
+ :mri_19 => Gem::Platform::RUBY,
18
+ :jruby => Gem::Platform::JAVA,
19
+ :mswin => Gem::Platform::MSWIN,
20
+ :mingw => Gem::Platform::MINGW,
21
+ :mingw_18 => Gem::Platform::MINGW,
22
+ :mingw_19 => Gem::Platform::MINGW
21
23
  }.freeze
22
24
 
23
25
  def initialize(name, version, options = {}, &blk)
@@ -115,5 +117,14 @@ module Bundler
115
117
  def mingw?
116
118
  Bundler::WINDOWS && Gem::Platform.local.os == "mingw32"
117
119
  end
120
+
121
+ def mingw_18?
122
+ mingw? && RUBY_VERSION < "1.9"
123
+ end
124
+
125
+ def mingw_19?
126
+ mingw? && RUBY_VERSION >= "1.9"
127
+ end
128
+
118
129
  end
119
130
  end
@@ -8,6 +8,9 @@ module Bundler
8
8
  i
9
9
  end
10
10
 
11
+ attr_reader :specs
12
+ protected :specs
13
+
11
14
  def initialize
12
15
  @cache = {}
13
16
  @specs = Hash.new { |h,k| h[k] = [] }
@@ -17,7 +20,10 @@ module Bundler
17
20
  super
18
21
  @cache = {}
19
22
  @specs = Hash.new { |h,k| h[k] = [] }
20
- merge!(o)
23
+
24
+ o.specs.each do |name, array|
25
+ @specs[name] = array.dup
26
+ end
21
27
  end
22
28
 
23
29
  def empty?
@@ -38,7 +44,7 @@ module Bundler
38
44
 
39
45
  wants_prerelease = dependency.requirement.prerelease?
40
46
  only_prerelease = specs.all? {|spec| spec.version.prerelease? }
41
- found = specs.select { |spec| dependency =~ spec }
47
+ found = specs.select { |spec| dependency.matches_spec?(spec) }
42
48
 
43
49
  unless wants_prerelease || only_prerelease
44
50
  found.reject! { |spec| spec.version.prerelease? }
@@ -59,7 +65,7 @@ module Bundler
59
65
  arr = @specs[spec.name]
60
66
 
61
67
  arr.delete_if do |s|
62
- s.version == spec.version && s.platform == spec.platform
68
+ same_version?(s.version, spec.version) && s.platform == spec.platform
63
69
  end
64
70
 
65
71
  arr << spec
@@ -91,17 +97,28 @@ module Bundler
91
97
 
92
98
  def search_by_spec(spec)
93
99
  @specs[spec.name].select do |s|
94
- s.version == spec.version && Gem::Platform.new(s.platform) == Gem::Platform.new(spec.platform)
100
+ same_version?(s.version, spec.version) && Gem::Platform.new(s.platform) == Gem::Platform.new(spec.platform)
95
101
  end
96
102
  end
97
103
 
104
+ def same_version?(a, b)
105
+ regex = /^(.*?)(?:\.0)*$/
106
+
107
+ ret = a.to_s[regex, 1] == b.to_s[regex, 1]
108
+ end
109
+
110
+ def spec_satisfies_dependency?(spec, dep)
111
+ return false unless dep.name === spec.name
112
+ dep.requirement.satisfied_by?(spec.version)
113
+ end
114
+
98
115
  def search_by_dependency(dependency)
99
116
  @cache[dependency.hash] ||= begin
100
117
  specs = @specs[dependency.name]
101
118
 
102
119
  wants_prerelease = dependency.requirement.prerelease?
103
120
  only_prerelease = specs.all? {|spec| spec.version.prerelease? }
104
- found = specs.select { |spec| dependency =~ spec && Gem::Platform.match(spec.platform) }
121
+ found = specs.select { |spec| dependency.matches_spec?(spec) && Gem::Platform.match(spec.platform) }
105
122
 
106
123
  unless wants_prerelease || only_prerelease
107
124
  found.reject! { |spec| spec.version.prerelease? }
@@ -111,4 +128,4 @@ module Bundler
111
128
  end
112
129
  end
113
130
  end
114
- end
131
+ end
@@ -121,9 +121,9 @@ module Bundler
121
121
  # ==== Returns
122
122
  # <GemBundle>,nil:: If the list of dependencies can be resolved, a
123
123
  # collection of gemspecs is returned. Otherwise, nil is returned.
124
- def self.resolve(requirements, index, source_requirements = {}, base = [], sort = true)
124
+ def self.resolve(requirements, index, source_requirements = {}, base = [])
125
125
  base = SpecSet.new(base) unless base.is_a?(SpecSet)
126
- resolver = new(index, source_requirements, base, sort)
126
+ resolver = new(index, source_requirements, base)
127
127
  result = catch(:success) do
128
128
  resolver.start(requirements)
129
129
  raise resolver.version_conflict
@@ -132,14 +132,14 @@ module Bundler
132
132
  SpecSet.new(result)
133
133
  end
134
134
 
135
- def initialize(index, source_requirements, base, sort)
135
+ def initialize(index, source_requirements, base)
136
136
  @errors = {}
137
137
  @stack = []
138
138
  @base = base
139
139
  @index = index
140
+ @gems_size = {}
140
141
  @missing_gems = Hash.new(0)
141
142
  @source_requirements = source_requirements
142
- @sort = sort
143
143
  end
144
144
 
145
145
  def debug
@@ -172,14 +172,12 @@ module Bundler
172
172
  # 1) Is this gem already activated?
173
173
  # 2) Do the version requirements include prereleased gems?
174
174
  # 3) Sort by number of gems available in the source.
175
- # This is a pretty expensive operation, so we skip it when the bundle is
176
- # locked and sorting isn't necessary.
177
175
  reqs = reqs.sort_by do |a|
178
176
  [ activated[a.name] ? 0 : 1,
179
177
  a.requirement.prerelease? ? 0 : 1,
180
178
  @errors[a.name] ? 0 : 1,
181
- activated[a.name] ? 0 : search(a).size ]
182
- end if @sort
179
+ activated[a.name] ? 0 : gems_size(a) ]
180
+ end
183
181
 
184
182
  debug { "Activated:\n" + activated.values.map { |a| " #{a.name} (#{a.version})" }.join("\n") }
185
183
  debug { "Requirements:\n" + reqs.map { |r| " #{r.name} (#{r.requirement})"}.join("\n") }
@@ -352,6 +350,10 @@ module Bundler
352
350
  retval
353
351
  end
354
352
 
353
+ def gems_size(dep)
354
+ @gems_size[dep] ||= search(dep).size
355
+ end
356
+
355
357
  def search(dep)
356
358
  if base = @base[dep.name] and base.any?
357
359
  d = Gem::Dependency.new(base.first.name, *[dep.requirement.as_list, base.first.version].flatten)
@@ -116,6 +116,20 @@ module Gem
116
116
  end
117
117
  out
118
118
  end
119
+
120
+ def matches_spec?(spec)
121
+ # name can be a Regexp, so use ===
122
+ return false unless name === spec.name
123
+ return true if requirement.none?
124
+
125
+ requirement.satisfied_by?(spec.version)
126
+ end unless allocate.respond_to?(:matches_spec?)
127
+ end
128
+
129
+ class Requirement
130
+ def none?
131
+ @none ||= (to_s == ">= 0")
132
+ end unless allocate.respond_to?(:none?)
119
133
  end
120
134
 
121
135
  class Platform
@@ -158,7 +158,7 @@ module Bundler
158
158
  @installed_specs ||= begin
159
159
  idx = Index.new
160
160
  have_bundler = false
161
- Gem::SourceIndex.from_installed_gems.to_a.reverse.each do |dont_use_this_var, spec|
161
+ Gem.source_index.to_a.reverse.each do |dont_use_this_var, spec|
162
162
  next if spec.name == 'bundler' && spec.version.to_s != VERSION
163
163
  have_bundler = true if spec.name == 'bundler'
164
164
  spec.source = self
@@ -185,27 +185,24 @@ module Bundler
185
185
 
186
186
  def cached_specs
187
187
  @cached_specs ||= begin
188
- idx = Index.new
189
- @caches.each do |path|
190
- Dir["#{path}/*.gem"].each do |gemfile|
191
- next if gemfile =~ /bundler\-[\d\.]+?\.gem/
192
-
193
- # Try to skip decompressing the gem to get at the gemspec if possible
194
- cached_gemspec = gemfile.gsub(%r{cache/(.*?)\.gem}, 'specifications/\1.gemspec')
195
- s = Gem::Specification.load(cached_gemspec) if File.exist?(cached_gemspec)
196
-
197
- begin
198
- s ||= Gem::Format.from_file_by_path(gemfile).spec
199
- rescue Gem::Package::FormatError
200
- raise GemspecError, "Could not read gem at #{gemfile}. It may be corrupted."
201
- end
188
+ idx = installed_specs.dup
202
189
 
203
- s.source = self
204
- idx << s
190
+ path = Bundler.app_cache
191
+ Dir["#{path}/*.gem"].each do |gemfile|
192
+ next if gemfile =~ /bundler\-[\d\.]+?\.gem/
193
+
194
+ begin
195
+ s ||= Gem::Format.from_file_by_path(gemfile).spec
196
+ rescue Gem::Package::FormatError
197
+ raise GemspecError, "Could not read gem at #{gemfile}. It may be corrupted."
205
198
  end
199
+
200
+ s.source = self
201
+ idx << s
206
202
  end
207
- idx
208
203
  end
204
+
205
+ idx
209
206
  end
210
207
 
211
208
  def remote_specs
@@ -530,7 +527,7 @@ module Bundler
530
527
  # TODO: actually cache git specs
531
528
  def specs
532
529
  if allow_git_ops? && !@update
533
- # Start by making sure the git cache is up to date
530
+ # Start by making sure the git cache is up to date
534
531
  cache
535
532
  checkout
536
533
  @update = true
@@ -612,7 +609,9 @@ module Bundler
612
609
  if cached?
613
610
  return if has_revision_cached?
614
611
  Bundler.ui.info "Updating #{uri}"
615
- in_cache { git %|fetch --force --quiet --tags "#{uri}" refs/heads/*:refs/heads/*| }
612
+ in_cache do
613
+ git %|fetch --force --quiet --tags "#{uri}" refs/heads/*:refs/heads/*|
614
+ end
616
615
  else
617
616
  Bundler.ui.info "Fetching #{uri}"
618
617
  FileUtils.mkdir_p(cache_path.dirname)
@@ -623,6 +622,7 @@ module Bundler
623
622
  def checkout
624
623
  unless File.exist?(path.join(".git"))
625
624
  FileUtils.mkdir_p(path.dirname)
625
+ FileUtils.rm_rf(path)
626
626
  git %|clone --no-checkout "#{cache_path}" "#{path}"|
627
627
  end
628
628
  Dir.chdir(path) do
@@ -667,5 +667,6 @@ module Bundler
667
667
  Dir.chdir(cache_path, &blk)
668
668
  end
669
669
  end
670
+
670
671
  end
671
672
  end
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
8
8
  s.platform = Gem::Platform::RUBY
9
9
  s.authors = ["TODO: Write your name"]
10
10
  s.email = ["TODO: Write your email address"]
11
- s.homepage = "http://rubygems.org/gems/<%=config[:name]%>"
11
+ s.homepage = ""
12
12
  s.summary = %q{TODO: Write a gem summary}
13
13
  s.description = %q{TODO: Write a gem description}
14
14
 
@@ -2,5 +2,5 @@ module Bundler
2
2
  # We're doing this because we might write tests that deal
3
3
  # with other versions of bundler and we are unsure how to
4
4
  # handle this better.
5
- VERSION = "1.0.5" unless defined?(::Bundler::VERSION)
5
+ VERSION = "1.0.7" unless defined?(::Bundler::VERSION)
6
6
  end
@@ -124,6 +124,12 @@ There are a number of `Gemfile` platforms:
124
124
  JRuby
125
125
  * `mswin`:
126
126
  Windows
127
+ * `mingw`:
128
+ Windows 'mingw32' platform (aka RubyInstaller)
129
+ * `mingw_18`:
130
+ _mingw_ `AND` version 1.8
131
+ * `mingw_19`:
132
+ _mingw_ `AND` version 1.9
127
133
 
128
134
  As with groups, you can specify one or more platforms:
129
135
 
@@ -175,4 +175,18 @@ describe "bundle install with platform conditionals" do
175
175
  G
176
176
  should_not_be_installed "nokogiri 1.4.2"
177
177
  end
178
+
179
+ it "does not blow up on sources with all platform-excluded specs" do
180
+ git = build_git "foo"
181
+
182
+ install_gemfile <<-G
183
+ platform :#{not_local_tag} do
184
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
185
+ end
186
+ G
187
+
188
+ bundle :show, :exitstatus => true
189
+ exitstatus.should == 0
190
+ end
191
+
178
192
  end
@@ -1,10 +1,6 @@
1
1
  require "spec_helper"
2
2
 
3
- describe "when using sudo" do
4
- before :each do
5
- pending "set BUNDLER_SUDO_TESTS to run sudo specs" unless test_sudo?
6
- end
7
-
3
+ describe "when using sudo", :sudo => true do
8
4
  describe "and GEM_HOME is owned by root" do
9
5
  before :each do
10
6
  chown_system_gems_to_root
@@ -40,6 +40,7 @@ RSpec.configure do |config|
40
40
  config.include Spec::Sudo
41
41
 
42
42
  config.filter_run :focused => true unless ENV['CI']
43
+ config.filter_run_excluding :sudo => true unless Spec::Sudo.test_sudo?
43
44
  config.run_all_when_everything_filtered = true
44
45
  config.alias_example_to :fit, :focused => true
45
46
 
@@ -81,3 +82,4 @@ RSpec.configure do |config|
81
82
  ENV['BUNDLE_APP_CONFIG'] = nil
82
83
  end
83
84
  end
85
+
@@ -1,5 +1,5 @@
1
1
  class IO
2
- def read_available_bytes(chunk_size = 1024, select_timeout = 5)
2
+ def read_available_bytes(chunk_size = 16384, select_timeout = 0.02)
3
3
  buffer = []
4
4
 
5
5
  return "" if closed? || eof?
@@ -7,8 +7,9 @@ class IO
7
7
  # just does not work on windows
8
8
  while true
9
9
  begin
10
+ IO.select([self], nil, nil, select_timeout)
11
+ break if eof? # stop raising :-(
10
12
  buffer << self.readpartial(chunk_size)
11
- sleep 0.1
12
13
  rescue(EOFError)
13
14
  break
14
15
  end
@@ -9,8 +9,11 @@ module Spec
9
9
 
10
10
  unless File.exist?("#{Path.base_system_gems}")
11
11
  FileUtils.mkdir_p(Path.base_system_gems)
12
- puts "running `gem install builder rake fakeweb --no-rdoc --no-ri`"
13
- `gem install builder rake fakeweb --no-rdoc --no-ri`
12
+ puts "running `gem install rake fakeweb --no-rdoc --no-ri`"
13
+ `gem install rake fakeweb --no-rdoc --no-ri`
14
+ # 3.0.0 breaks 1.9.2 specs
15
+ puts "running `gem install builder --version 2.1.2 --no-rdoc --no-ri`"
16
+ `gem install builder --version 2.1.2 --no-rdoc --no-ri`
14
17
  end
15
18
 
16
19
  ENV['HOME'] = Path.home.to_s
@@ -2,11 +2,11 @@ module Spec
2
2
  module Sudo
3
3
  def self.present?
4
4
  @which_sudo ||= (`which sudo`.chomp rescue '')
5
- !@which_sudo.empty? && ENV['BUNDLER_SUDO_TESTS']
5
+ !@which_sudo.empty?
6
6
  end
7
7
 
8
- def test_sudo?
9
- Sudo.present?
8
+ def self.test_sudo?
9
+ present? && ENV['BUNDLER_SUDO_TESTS']
10
10
  end
11
11
 
12
12
  def sudo(cmd)
@@ -18,4 +18,4 @@ module Spec
18
18
  sudo "chown -R root #{system_gem_path}"
19
19
  end
20
20
  end
21
- end
21
+ end
@@ -178,5 +178,19 @@ describe "bundle update" do
178
178
  out.should == 'GEM'
179
179
  end
180
180
  end
181
+
182
+ it "errors with a message when the .git repo is gone" do
183
+ build_git "foo", "1.0"
184
+
185
+ install_gemfile <<-G
186
+ gem "foo", :git => "#{lib_path('foo-1.0')}"
187
+ G
188
+
189
+ lib_path("foo-1.0").join(".git").rmtree
190
+
191
+ bundle :update, :expect_err => true
192
+ out.should include(lib_path("foo-1.0").to_s)
193
+ end
194
+
181
195
  end
182
196
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bundler
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 25
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 0
9
- - 5
10
- version: 1.0.5
9
+ - 7
10
+ version: 1.0.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Carl Lerche
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2010-11-13 00:00:00 -06:00
20
+ date: 2010-11-17 00:00:00 -08:00
21
21
  default_executable: bundle
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency