bundler 2.2.21 → 2.2.25

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.

Files changed (67) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +63 -0
  3. data/lib/bundler.rb +4 -9
  4. data/lib/bundler/build_metadata.rb +2 -2
  5. data/lib/bundler/cli.rb +7 -0
  6. data/lib/bundler/cli/cache.rb +1 -1
  7. data/lib/bundler/cli/doctor.rb +12 -2
  8. data/lib/bundler/cli/install.rb +5 -18
  9. data/lib/bundler/cli/list.rb +7 -1
  10. data/lib/bundler/cli/lock.rb +5 -1
  11. data/lib/bundler/cli/open.rb +1 -2
  12. data/lib/bundler/cli/update.rb +9 -4
  13. data/lib/bundler/current_ruby.rb +4 -4
  14. data/lib/bundler/definition.rb +48 -93
  15. data/lib/bundler/dsl.rb +23 -21
  16. data/lib/bundler/feature_flag.rb +0 -1
  17. data/lib/bundler/fetcher/downloader.rb +1 -2
  18. data/lib/bundler/index.rb +1 -5
  19. data/lib/bundler/installer.rb +4 -4
  20. data/lib/bundler/installer/gem_installer.rb +3 -16
  21. data/lib/bundler/installer/standalone.rb +1 -1
  22. data/lib/bundler/lockfile_parser.rb +3 -20
  23. data/lib/bundler/man/bundle-add.1 +1 -1
  24. data/lib/bundler/man/bundle-binstubs.1 +1 -1
  25. data/lib/bundler/man/bundle-cache.1 +1 -1
  26. data/lib/bundler/man/bundle-check.1 +1 -1
  27. data/lib/bundler/man/bundle-clean.1 +1 -1
  28. data/lib/bundler/man/bundle-config.1 +1 -4
  29. data/lib/bundler/man/bundle-config.1.ronn +0 -3
  30. data/lib/bundler/man/bundle-doctor.1 +1 -1
  31. data/lib/bundler/man/bundle-exec.1 +1 -1
  32. data/lib/bundler/man/bundle-gem.1 +1 -1
  33. data/lib/bundler/man/bundle-info.1 +1 -1
  34. data/lib/bundler/man/bundle-init.1 +1 -1
  35. data/lib/bundler/man/bundle-inject.1 +1 -1
  36. data/lib/bundler/man/bundle-install.1 +1 -1
  37. data/lib/bundler/man/bundle-list.1 +1 -1
  38. data/lib/bundler/man/bundle-lock.1 +1 -1
  39. data/lib/bundler/man/bundle-open.1 +1 -1
  40. data/lib/bundler/man/bundle-outdated.1 +1 -1
  41. data/lib/bundler/man/bundle-platform.1 +1 -1
  42. data/lib/bundler/man/bundle-pristine.1 +1 -1
  43. data/lib/bundler/man/bundle-remove.1 +1 -1
  44. data/lib/bundler/man/bundle-show.1 +1 -1
  45. data/lib/bundler/man/bundle-update.1 +4 -4
  46. data/lib/bundler/man/bundle-update.1.ronn +3 -3
  47. data/lib/bundler/man/bundle-viz.1 +1 -1
  48. data/lib/bundler/man/bundle.1 +1 -1
  49. data/lib/bundler/man/gemfile.5 +1 -1
  50. data/lib/bundler/plugin.rb +2 -0
  51. data/lib/bundler/plugin/index.rb +4 -1
  52. data/lib/bundler/plugin/installer.rb +1 -1
  53. data/lib/bundler/resolver.rb +1 -1
  54. data/lib/bundler/rubygems_ext.rb +22 -6
  55. data/lib/bundler/rubygems_gem_installer.rb +5 -1
  56. data/lib/bundler/runtime.rb +16 -9
  57. data/lib/bundler/settings.rb +4 -7
  58. data/lib/bundler/setup.rb +2 -2
  59. data/lib/bundler/shared_helpers.rb +0 -7
  60. data/lib/bundler/source/git/git_proxy.rb +1 -2
  61. data/lib/bundler/source/rubygems.rb +5 -14
  62. data/lib/bundler/source_list.rb +50 -20
  63. data/lib/bundler/spec_set.rb +15 -42
  64. data/lib/bundler/templates/Executable.bundler +6 -6
  65. data/lib/bundler/version.rb +1 -1
  66. data/lib/bundler/worker.rb +17 -2
  67. metadata +3 -3
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE\-OUTDATED" "1" "May 2021" "" ""
4
+ .TH "BUNDLE\-OUTDATED" "1" "June 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-outdated\fR \- List installed gems with newer versions available
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE\-PLATFORM" "1" "May 2021" "" ""
4
+ .TH "BUNDLE\-PLATFORM" "1" "June 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-platform\fR \- Displays platform compatibility information
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE\-PRISTINE" "1" "May 2021" "" ""
4
+ .TH "BUNDLE\-PRISTINE" "1" "June 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-pristine\fR \- Restores installed gems to their pristine condition
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE\-REMOVE" "1" "May 2021" "" ""
4
+ .TH "BUNDLE\-REMOVE" "1" "June 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-remove\fR \- Removes gems from the Gemfile
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE\-SHOW" "1" "May 2021" "" ""
4
+ .TH "BUNDLE\-SHOW" "1" "June 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-show\fR \- Shows all the gems in your bundle, or the path to a gem
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE\-UPDATE" "1" "May 2021" "" ""
4
+ .TH "BUNDLE\-UPDATE" "1" "June 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-update\fR \- Update your gems to the latest available versions
@@ -79,7 +79,7 @@ Do not allow any gem to be updated past latest \fB\-\-patch\fR | \fB\-\-minor\fR
79
79
  .
80
80
  .TP
81
81
  \fB\-\-conservative\fR
82
- Use bundle install conservative update behavior and do not allow shared dependencies to be updated\.
82
+ Use bundle install conservative update behavior and do not allow indirect dependencies to be updated\.
83
83
  .
84
84
  .SH "UPDATING ALL GEMS"
85
85
  If you run \fBbundle update \-\-all\fR, bundler will ignore any previously installed gems and resolve all dependencies again based on the latest versions of all gems available in the sources\.
@@ -208,13 +208,13 @@ In this case, the two gems have their own set of dependencies, but they share \f
208
208
  In short, by default, when you update a gem using \fBbundle update\fR, bundler will update all dependencies of that gem, including those that are also dependencies of another gem\.
209
209
  .
210
210
  .P
211
- To prevent updating shared dependencies, prior to version 1\.14 the only option was the \fBCONSERVATIVE UPDATING\fR behavior in bundle install(1) \fIbundle\-install\.1\.html\fR:
211
+ To prevent updating indirect dependencies, prior to version 1\.14 the only option was the \fBCONSERVATIVE UPDATING\fR behavior in bundle install(1) \fIbundle\-install\.1\.html\fR:
212
212
  .
213
213
  .P
214
214
  In this scenario, updating the \fBthin\fR version manually in the Gemfile(5), and then running bundle install(1) \fIbundle\-install\.1\.html\fR will only update \fBdaemons\fR and \fBeventmachine\fR, but not \fBrack\fR\. For more information, see the \fBCONSERVATIVE UPDATING\fR section of bundle install(1) \fIbundle\-install\.1\.html\fR\.
215
215
  .
216
216
  .P
217
- Starting with 1\.14, specifying the \fB\-\-conservative\fR option will also prevent shared dependencies from being updated\.
217
+ Starting with 1\.14, specifying the \fB\-\-conservative\fR option will also prevent indirect dependencies from being updated\.
218
218
  .
219
219
  .SH "PATCH LEVEL OPTIONS"
220
220
  Version 1\.14 introduced 4 patch\-level options that will influence how gem versions are resolved\. One of the following options can be used: \fB\-\-patch\fR, \fB\-\-minor\fR or \fB\-\-major\fR\. \fB\-\-strict\fR can be added to further influence resolution\.
@@ -80,7 +80,7 @@ gem.
80
80
  Do not allow any gem to be updated past latest `--patch` | `--minor` | `--major`.
81
81
 
82
82
  * `--conservative`:
83
- Use bundle install conservative update behavior and do not allow shared dependencies to be updated.
83
+ Use bundle install conservative update behavior and do not allow indirect dependencies to be updated.
84
84
 
85
85
  ## UPDATING ALL GEMS
86
86
 
@@ -195,7 +195,7 @@ In short, by default, when you update a gem using `bundle update`, bundler will
195
195
  update all dependencies of that gem, including those that are also dependencies
196
196
  of another gem.
197
197
 
198
- To prevent updating shared dependencies, prior to version 1.14 the only option
198
+ To prevent updating indirect dependencies, prior to version 1.14 the only option
199
199
  was the `CONSERVATIVE UPDATING` behavior in [bundle install(1)](bundle-install.1.html):
200
200
 
201
201
  In this scenario, updating the `thin` version manually in the Gemfile(5),
@@ -203,7 +203,7 @@ and then running [bundle install(1)](bundle-install.1.html) will only update `da
203
203
  but not `rack`. For more information, see the `CONSERVATIVE UPDATING` section
204
204
  of [bundle install(1)](bundle-install.1.html).
205
205
 
206
- Starting with 1.14, specifying the `--conservative` option will also prevent shared
206
+ Starting with 1.14, specifying the `--conservative` option will also prevent indirect
207
207
  dependencies from being updated.
208
208
 
209
209
  ## PATCH LEVEL OPTIONS
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE\-VIZ" "1" "May 2021" "" ""
4
+ .TH "BUNDLE\-VIZ" "1" "June 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\-viz\fR \- Generates a visual dependency graph for your Gemfile
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "BUNDLE" "1" "May 2021" "" ""
4
+ .TH "BUNDLE" "1" "June 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBbundle\fR \- Ruby Dependency Management
@@ -1,7 +1,7 @@
1
1
  .\" generated with Ronn/v0.7.3
2
2
  .\" http://github.com/rtomayko/ronn/tree/0.7.3
3
3
  .
4
- .TH "GEMFILE" "5" "May 2021" "" ""
4
+ .TH "GEMFILE" "5" "June 2021" "" ""
5
5
  .
6
6
  .SH "NAME"
7
7
  \fBGemfile\fR \- A format for describing gem dependencies for Ruby programs
@@ -309,6 +309,8 @@ module Bundler
309
309
  #
310
310
  # @param [String] name of the plugin
311
311
  def load_plugin(name)
312
+ return unless name && !name.empty?
313
+
312
314
  # Need to ensure before this that plugin root where the rest of gems
313
315
  # are installed to be on load path to support plugin deps. Currently not
314
316
  # done to avoid conflicts
@@ -74,7 +74,10 @@ module Bundler
74
74
  def unregister_plugin(name)
75
75
  @commands.delete_if {|_, v| v == name }
76
76
  @sources.delete_if {|_, v| v == name }
77
- @hooks.each {|_, plugin_names| plugin_names.delete(name) }
77
+ @hooks.each do |hook, names|
78
+ names.delete(name)
79
+ @hooks.delete(hook) if names.empty?
80
+ end
78
81
  @plugin_paths.delete(name)
79
82
  @load_paths.delete(name)
80
83
  save_index
@@ -77,7 +77,7 @@ module Bundler
77
77
  source_list = SourceList.new
78
78
 
79
79
  source_list.add_git_source(git_source_options) if git_source_options
80
- source_list.global_rubygems_source = rubygems_source if rubygems_source
80
+ Array(rubygems_source).each {|remote| source_list.add_global_rubygems_remote(remote) } if rubygems_source
81
81
 
82
82
  deps = names.map {|name| Dependency.new name, version }
83
83
 
@@ -21,7 +21,7 @@ module Bundler
21
21
  base = SpecSet.new(base) unless base.is_a?(SpecSet)
22
22
  resolver = new(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
23
23
  result = resolver.start(requirements)
24
- SpecSet.new(result).for(requirements.reject{|dep| dep.name.end_with?("\0") })
24
+ SpecSet.new(SpecSet.new(result).for(requirements.reject{|dep| dep.name.end_with?("\0") }))
25
25
  end
26
26
 
27
27
  def initialize(source_requirements, base, gem_version_promoter, additional_base_requirements, platforms)
@@ -174,20 +174,36 @@ module Gem
174
174
  end
175
175
  end
176
176
 
177
+ require "rubygems/platform"
178
+
177
179
  class Platform
178
180
  JAVA = Gem::Platform.new("java") unless defined?(JAVA)
179
181
  MSWIN = Gem::Platform.new("mswin32") unless defined?(MSWIN)
180
182
  MSWIN64 = Gem::Platform.new("mswin64") unless defined?(MSWIN64)
181
183
  MINGW = Gem::Platform.new("x86-mingw32") unless defined?(MINGW)
182
184
  X64_MINGW = Gem::Platform.new("x64-mingw32") unless defined?(X64_MINGW)
185
+ end
183
186
 
184
- undef_method :hash if method_defined? :hash
185
- def hash
186
- @cpu.hash ^ @os.hash ^ @version.hash
187
- end
187
+ Platform.singleton_class.module_eval do
188
+ unless Platform.singleton_methods.include?(:match_spec?)
189
+ def match_spec?(spec)
190
+ match_gem?(spec.platform, spec.name)
191
+ end
188
192
 
189
- undef_method :eql? if method_defined? :eql?
190
- alias_method :eql?, :==
193
+ def match_gem?(platform, gem_name)
194
+ match_platforms?(platform, Gem.platforms)
195
+ end
196
+
197
+ private
198
+
199
+ def match_platforms?(platform, platforms)
200
+ platforms.any? do |local_platform|
201
+ platform.nil? ||
202
+ local_platform == platform ||
203
+ (local_platform != Gem::Platform::RUBY && local_platform =~ platform)
204
+ end
205
+ end
206
+ end
191
207
  end
192
208
 
193
209
  require "rubygems/util"
@@ -61,7 +61,10 @@ module Bundler
61
61
 
62
62
  def build_extensions
63
63
  extension_cache_path = options[:bundler_extension_cache_path]
64
- return super unless extension_cache_path && extension_dir = spec.extension_dir
64
+ unless extension_cache_path && extension_dir = spec.extension_dir
65
+ require "shellwords" # compensate missing require in rubygems before version 3.2.25
66
+ return super
67
+ end
65
68
 
66
69
  extension_dir = Pathname.new(extension_dir)
67
70
  build_complete = SharedHelpers.filesystem_access(extension_cache_path.join("gem.build_complete"), :read, &:file?)
@@ -71,6 +74,7 @@ module Bundler
71
74
  FileUtils.cp_r extension_cache_path, spec.extension_dir
72
75
  end
73
76
  else
77
+ require "shellwords" # compensate missing require in rubygems before version 3.2.25
74
78
  super
75
79
  if extension_dir.directory? # not made for gems without extensions
76
80
  SharedHelpers.filesystem_access(extension_cache_path.parent, &:mkpath)
@@ -12,22 +12,16 @@ module Bundler
12
12
  def setup(*groups)
13
13
  @definition.ensure_equivalent_gemfile_and_lockfile if Bundler.frozen_bundle?
14
14
 
15
- groups.map!(&:to_sym)
16
-
17
15
  # Has to happen first
18
16
  clean_load_path
19
17
 
20
- specs = groups.any? ? @definition.specs_for(groups) : requested_specs
18
+ specs = @definition.specs_for(groups)
21
19
 
22
20
  SharedHelpers.set_bundle_environment
23
21
  Bundler.rubygems.replace_entrypoints(specs)
24
22
 
25
23
  # Activate the specs
26
24
  load_paths = specs.map do |spec|
27
- unless spec.loaded_from
28
- raise GemNotFound, "#{spec.full_name} is missing. Run `bundle install` to get it."
29
- end
30
-
31
25
  check_for_activated_spec!(spec)
32
26
 
33
27
  Bundler.rubygems.mark_loaded(spec)
@@ -106,7 +100,7 @@ module Bundler
106
100
 
107
101
  alias_method :gems, :specs
108
102
 
109
- def cache(custom_path = nil)
103
+ def cache(custom_path = nil, local = false)
110
104
  cache_path = Bundler.app_cache(custom_path)
111
105
  SharedHelpers.filesystem_access(cache_path) do |p|
112
106
  FileUtils.mkdir_p(p)
@@ -114,7 +108,20 @@ module Bundler
114
108
 
115
109
  Bundler.ui.info "Updating files in #{Bundler.settings.app_cache_path}"
116
110
 
117
- specs_to_cache = Bundler.settings[:cache_all_platforms] ? @definition.resolve.materialized_for_all_platforms : specs
111
+ specs_to_cache = if Bundler.settings[:cache_all_platforms]
112
+ @definition.resolve.materialized_for_all_platforms
113
+ else
114
+ begin
115
+ specs
116
+ rescue GemNotFound
117
+ if local
118
+ Bundler.ui.warn "Some gems seem to be missing from your #{Bundler.settings.app_cache_path} directory."
119
+ end
120
+
121
+ raise
122
+ end
123
+ end
124
+
118
125
  specs_to_cache.each do |spec|
119
126
  next if spec.name == "bundler"
120
127
  next if spec.source.is_a?(Source::Gemspec)
@@ -44,7 +44,6 @@ module Bundler
44
44
  silence_deprecations
45
45
  silence_root_warning
46
46
  suppress_install_using_messages
47
- unlock_source_unlocks_spec
48
47
  update_requires_all_flag
49
48
  use_gem_version_promoter_for_major_updates
50
49
  ].freeze
@@ -429,12 +428,10 @@ module Bundler
429
428
  def global_config_file
430
429
  if ENV["BUNDLE_CONFIG"] && !ENV["BUNDLE_CONFIG"].empty?
431
430
  Pathname.new(ENV["BUNDLE_CONFIG"])
432
- else
433
- begin
434
- Bundler.user_bundle_path("config")
435
- rescue PermissionError, GenericSystemCallError
436
- nil
437
- end
431
+ elsif ENV["BUNDLE_USER_CONFIG"] && !ENV["BUNDLE_USER_CONFIG"].empty?
432
+ Pathname.new(ENV["BUNDLE_USER_CONFIG"])
433
+ elsif Bundler.rubygems.user_home && !Bundler.rubygems.user_home.empty?
434
+ Pathname.new(Bundler.rubygems.user_home).join(".bundle/config")
438
435
  end
439
436
  end
440
437
 
data/lib/bundler/setup.rb CHANGED
@@ -9,10 +9,10 @@ if Bundler::SharedHelpers.in_bundle?
9
9
  begin
10
10
  Bundler.ui.silence { Bundler.setup }
11
11
  rescue Bundler::BundlerError => e
12
- Bundler.ui.warn "\e[31m#{e.message}\e[0m"
12
+ Bundler.ui.error e.message
13
13
  Bundler.ui.warn e.backtrace.join("\n") if ENV["DEBUG"]
14
14
  if e.is_a?(Bundler::GemNotFound)
15
- Bundler.ui.warn "\e[33mRun `bundle install` to install missing gems.\e[0m"
15
+ Bundler.ui.warn "Run `bundle install` to install missing gems."
16
16
  end
17
17
  exit e.status_code
18
18
  end
@@ -152,13 +152,6 @@ module Bundler
152
152
  Bundler.ui.warn message
153
153
  end
154
154
 
155
- def trap(signal, override = false, &block)
156
- prior = Signal.trap(signal) do
157
- block.call
158
- prior.call unless override
159
- end
160
- end
161
-
162
155
  def ensure_same_dependencies(spec, old_deps, new_deps)
163
156
  new_deps = new_deps.reject {|d| d.type == :development }
164
157
  old_deps = old_deps.reject {|d| d.type == :development }
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "shellwords"
4
-
5
3
  module Bundler
6
4
  class Source
7
5
  class Git
@@ -224,6 +222,7 @@ module Bundler
224
222
  end
225
223
 
226
224
  def check_allowed(command)
225
+ require "shellwords"
227
226
  command_with_no_credentials = URICredentialsFilter.credential_filtered_string("git #{command.shelljoin}", uri)
228
227
  raise GitNotAllowedError.new(command_with_no_credentials) unless allow?
229
228
  command_with_no_credentials
@@ -71,9 +71,13 @@ module Bundler
71
71
  @remotes.size > 1
72
72
  end
73
73
 
74
+ def no_remotes?
75
+ @remotes.size == 0
76
+ end
77
+
74
78
  def can_lock?(spec)
75
79
  return super unless multiple_remotes?
76
- spec.source.is_a?(Rubygems)
80
+ include?(spec.source)
77
81
  end
78
82
 
79
83
  def options
@@ -252,19 +256,6 @@ module Bundler
252
256
  other_remotes.map(&method(:remove_auth)) == @remotes.map(&method(:remove_auth))
253
257
  end
254
258
 
255
- def replace_remotes(other_remotes, allow_equivalent = false)
256
- return false if other_remotes == @remotes
257
-
258
- equivalent = allow_equivalent && equivalent_remotes?(other_remotes)
259
-
260
- @remotes = []
261
- other_remotes.reverse_each do |r|
262
- add_remote r.to_s
263
- end
264
-
265
- !equivalent
266
- end
267
-
268
259
  def spec_names
269
260
  if @allow_remote && dependency_api_available?
270
261
  remote_specs.spec_names
@@ -28,14 +28,19 @@ module Bundler
28
28
  @merged_gem_lockfile_sections
29
29
  end
30
30
 
31
- def merged_gem_lockfile_sections!
31
+ def merged_gem_lockfile_sections!(replacement_source)
32
32
  @merged_gem_lockfile_sections = true
33
+ @global_rubygems_source = replacement_source
33
34
  end
34
35
 
35
36
  def aggregate_global_source?
36
37
  global_rubygems_source.multiple_remotes?
37
38
  end
38
39
 
40
+ def implicit_global_source?
41
+ global_rubygems_source.no_remotes?
42
+ end
43
+
39
44
  def add_path_source(options = {})
40
45
  if options["gemspec"]
41
46
  add_source_to_list Source::Gemspec.new(options), path_sources
@@ -53,18 +58,17 @@ module Bundler
53
58
  end
54
59
 
55
60
  def add_rubygems_source(options = {})
56
- add_source_to_list Source::Rubygems.new(options), @rubygems_sources
61
+ new_source = Source::Rubygems.new(options)
62
+ return @global_rubygems_source if @global_rubygems_source == new_source
63
+
64
+ add_source_to_list new_source, @rubygems_sources
57
65
  end
58
66
 
59
67
  def add_plugin_source(source, options = {})
60
68
  add_source_to_list Plugin.source(source).new(options), @plugin_sources
61
69
  end
62
70
 
63
- def global_rubygems_source=(uri)
64
- @global_rubygems_source ||= rubygems_aggregate_class.new("remotes" => uri, "allow_local" => true)
65
- end
66
-
67
- def add_rubygems_remote(uri)
71
+ def add_global_rubygems_remote(uri)
68
72
  global_rubygems_source.add_remote(uri)
69
73
  global_rubygems_source
70
74
  end
@@ -109,27 +113,27 @@ module Bundler
109
113
  if merged_gem_lockfile_sections?
110
114
  [combine_rubygems_sources]
111
115
  else
112
- rubygems_sources.sort_by(&:to_s).uniq
116
+ rubygems_sources.sort_by(&:to_s)
113
117
  end
114
118
  end
115
119
 
116
120
  # Returns true if there are changes
117
121
  def replace_sources!(replacement_sources)
118
- return true if replacement_sources.empty?
122
+ return false if replacement_sources.empty?
119
123
 
120
- [path_sources, git_sources, plugin_sources].each do |source_list|
121
- source_list.map! do |source|
122
- replacement_sources.find {|s| s == source } || source
123
- end
124
- end
124
+ @rubygems_sources, @path_sources, @git_sources, @plugin_sources = map_sources(replacement_sources)
125
+ @global_rubygems_source = global_replacement_source(replacement_sources)
126
+
127
+ different_sources?(lock_sources, replacement_sources)
128
+ end
125
129
 
126
- replacement_rubygems = merged_gem_lockfile_sections? &&
127
- replacement_sources.detect {|s| s.is_a?(Source::Rubygems) }
128
- @global_rubygems_source = replacement_rubygems if replacement_rubygems
130
+ # Returns true if there are changes
131
+ def expired_sources?(replacement_sources)
132
+ return false if replacement_sources.empty?
129
133
 
130
- return true if !equal_sources?(lock_sources, replacement_sources) && !equivalent_sources?(lock_sources, replacement_sources)
134
+ lock_sources = dup_with_replaced_sources(replacement_sources).lock_sources
131
135
 
132
- false
136
+ different_sources?(lock_sources, replacement_sources)
133
137
  end
134
138
 
135
139
  def local_only!
@@ -146,6 +150,32 @@ module Bundler
146
150
 
147
151
  private
148
152
 
153
+ def dup_with_replaced_sources(replacement_sources)
154
+ new_source_list = dup
155
+ new_source_list.replace_sources!(replacement_sources)
156
+ new_source_list
157
+ end
158
+
159
+ def map_sources(replacement_sources)
160
+ [@rubygems_sources, @path_sources, @git_sources, @plugin_sources].map do |sources|
161
+ sources.map do |source|
162
+ replacement_sources.find {|s| s == source } || source
163
+ end
164
+ end
165
+ end
166
+
167
+ def global_replacement_source(replacement_sources)
168
+ replacement_source = replacement_sources.find {|s| s == global_rubygems_source }
169
+ return global_rubygems_source unless replacement_source
170
+
171
+ replacement_source.local!
172
+ replacement_source
173
+ end
174
+
175
+ def different_sources?(lock_sources, replacement_sources)
176
+ !equal_sources?(lock_sources, replacement_sources) && !equivalent_sources?(lock_sources, replacement_sources)
177
+ end
178
+
149
179
  def rubygems_aggregate_class
150
180
  Source::Rubygems
151
181
  end
@@ -185,7 +215,7 @@ module Bundler
185
215
  end
186
216
 
187
217
  def equal_source?(source, other_source)
188
- return source.include?(other_source) if source.is_a?(Source::Rubygems) && other_source.is_a?(Source::Rubygems) && !merged_gem_lockfile_sections?
218
+ return source.include?(other_source) if source.is_a?(Source::Rubygems) && other_source.is_a?(Source::Rubygems)
189
219
 
190
220
  source == other_source
191
221
  end