bundler 1.6.9 → 1.7.0

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.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 416e8ee36efa63219a479a3f0b05a2e9c3cbff1c
4
- data.tar.gz: bcdb1aba2bddb5787e77a692f2f3c1ad80960029
3
+ metadata.gz: 155503cb2801c3408a1a6290488e86d95fc44377
4
+ data.tar.gz: 155ff56ba76e00285762682095374af6978dc701
5
5
  SHA512:
6
- metadata.gz: 2b128dcdbe2c790eb2304554b23a17abee78f6cb23d3abcda0acf65e2dd1cecc6d1d3aadc3c8bb16cddc3e1bca7c76fef15e52bd4b9b3251493d0b4f910d4bad
7
- data.tar.gz: afcf5192a0252af39937b528f008d59e133631fb6eb31ebe42c1aee7dfac673e7a6aa305b914d000968bd1b8cc1f227d5feb5b85f201ead3be145ebdceee6134
6
+ metadata.gz: 79b16bf6b319c496e5dd80d74582217e9def1ca17f937c7173e20b973066064406d0a21f092e175a504ad1743ee86ff17b56639c336b3c78ea621485b790cea8
7
+ data.tar.gz: c61d725503a3ac4d74a1708ee30ce80bea1b075118df1bc054c0339fd538809284f2dcda20057bba1950ae1414297118dc869cf1d6752f3fa0d09001522d0b83
@@ -4,6 +4,7 @@ before_script: travis_retry rake spec:travis:deps
4
4
  branches:
5
5
  only:
6
6
  - master
7
+ - 1-7-stable
7
8
  - 1-6-stable
8
9
  - 1-5-stable
9
10
  - 1-3-stable
@@ -1,30 +1,17 @@
1
- ## 1.6.9 (2014-11-11)
1
+ ## 1.7.0 (2014-08-13)
2
2
 
3
- Features:
4
-
5
- - alternate certificates that work with all OpenSSLs (@luislavena, @indirect)
6
-
7
- ## 1.6.8 (2014-11-10)
8
-
9
- Features:
10
-
11
- - vendor new certificates to validate HTTPS with rubygems.org (@indirect)
3
+ Security:
12
4
 
13
- ## 1.6.7 (2014-10-19)
5
+ - Fix for CVE-2013-0334, installing gems from an unexpected source
14
6
 
15
7
  Features:
16
8
 
17
- - warn to upgrade when using useless source blocks (@danfinnie)
18
-
19
- Documentation:
20
-
21
- - explain how to use gem server credentials via ENV (@hwartig)
22
-
23
- ## 1.6.6 (2014-08-23)
9
+ - Gemfile `source` calls now take a block containing gems from that source (@tmoore)
10
+ - added the `:source` option to `gem` to specify a source (@tmoore)
24
11
 
25
12
  Bugfixes:
26
13
 
27
- - restore Gemfile credentials to Gemfile.lock (@indirect)
14
+ - warn on ambiguous gems available from more than one source (@tmoore)
28
15
 
29
16
  ## 1.6.5 (2014-07-23)
30
17
 
data/Rakefile CHANGED
@@ -41,7 +41,7 @@ namespace :spec do
41
41
  deps.delete("rdiscount")
42
42
  end
43
43
 
44
- deps.sort_by{|name, _| name }.each do |name, version|
44
+ deps.each do |name, version|
45
45
  sh "#{Gem.ruby} -S gem list -i '^#{name}$' -v '#{version}' || " \
46
46
  "#{Gem.ruby} -S gem install #{name} -v '#{version}' --no-ri --no-rdoc"
47
47
  end
@@ -129,7 +129,7 @@ begin
129
129
  end
130
130
 
131
131
  task "clone_rubygems_#{rg}" do
132
- unless File.directory?(RUBYGEMS_REPO)
132
+ unless File.directory?("tmp/rubygems")
133
133
  system("git clone https://github.com/rubygems/rubygems.git tmp/rubygems")
134
134
  end
135
135
  hash = nil
@@ -16,7 +16,6 @@ Gem::Specification.new do |spec|
16
16
  spec.required_ruby_version = '>= 1.8.7'
17
17
  spec.required_rubygems_version = '>= 1.3.6'
18
18
 
19
- spec.add_development_dependency 'mustache', '0.99.6'
20
19
  spec.add_development_dependency 'rdiscount', '~> 1.6'
21
20
  spec.add_development_dependency 'ronn', '~> 0.7.3'
22
21
  spec.add_development_dependency 'rspec', '~> 3.0.0.beta1'
@@ -41,6 +41,7 @@ module Bundler
41
41
  autoload :SharedHelpers, 'bundler/shared_helpers'
42
42
  autoload :SpecSet, 'bundler/spec_set'
43
43
  autoload :Source, 'bundler/source'
44
+ autoload :SourceList, 'bundler/source_list'
44
45
  autoload :Specification, 'bundler/shared_helpers'
45
46
  autoload :SystemRubyVersion, 'bundler/ruby_version'
46
47
  autoload :UI, 'bundler/ui'
@@ -23,7 +23,7 @@ module Bundler
23
23
  def setup_cache_all
24
24
  Bundler.settings[:cache_all] = options[:all] if options.key?("all")
25
25
 
26
- if Bundler.definition.sources.any? { |s| !s.is_a?(Source::Rubygems) } && !Bundler.settings[:cache_all]
26
+ if Bundler.definition.has_local_dependencies? && !Bundler.settings[:cache_all]
27
27
  Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \
28
28
  "to package them as well, please pass the --all flag. This will be the default " \
29
29
  "on Bundler 2.0."
@@ -93,6 +93,15 @@ module Bundler
93
93
  Bundler.ui.confirm "Post-install message from #{name}:"
94
94
  Bundler.ui.info msg
95
95
  end
96
+ Installer.ambiguous_gems.to_a.each do |name, installed_from_uri, *also_found_in_uris|
97
+ Bundler.ui.error "Warning: the gem '#{name}' was found in multiple sources."
98
+ Bundler.ui.error "Installed from: #{installed_from_uri}"
99
+ Bundler.ui.error "Also found in:"
100
+ also_found_in_uris.each { |uri| Bundler.ui.error " * #{uri}" }
101
+ Bundler.ui.error "You should add a source requirement to restrict this gem to your preferred source."
102
+ Bundler.ui.error "For example:"
103
+ Bundler.ui.error " gem '#{name}', :source => '#{installed_from_uri}'"
104
+ end
96
105
 
97
106
  if Bundler.settings[:clean] && Bundler.settings[:path]
98
107
  require "bundler/cli/clean"
@@ -103,7 +112,7 @@ module Bundler
103
112
  Bundler.ui.warn "Some gems seem to be missing from your vendor/cache directory."
104
113
  end
105
114
 
106
- if Bundler.definition.rubygems_remotes.empty?
115
+ unless Bundler.definition.has_rubygems_remotes?
107
116
  Bundler.ui.warn <<-WARN, :wrap => true
108
117
  Your Gemfile has no gem server sources. If you need gems that are \
109
118
  not already on your machine, add a line like this to your Gemfile:
@@ -26,7 +26,7 @@ module Bundler
26
26
  def setup_cache_all
27
27
  Bundler.settings[:cache_all] = options[:all] if options.key?("all")
28
28
 
29
- if Bundler.definition.sources.any? { |s| !s.is_a?(Source::Rubygems) } && !Bundler.settings[:cache_all]
29
+ if Bundler.definition.has_local_dependencies? && !Bundler.settings[:cache_all]
30
30
  Bundler.ui.warn "Your Gemfile contains path and git dependencies. If you want " \
31
31
  "to package them as well, please pass the --all flag. This will be the default " \
32
32
  "on Bundler 2.0."
@@ -5,8 +5,7 @@ module Bundler
5
5
  class Definition
6
6
  include GemHelpers
7
7
 
8
- attr_reader :dependencies, :platforms, :sources, :ruby_version,
9
- :locked_deps
8
+ attr_reader :dependencies, :platforms, :ruby_version, :locked_deps
10
9
 
11
10
  # Given a gemfile and lockfile creates a Bundler definition
12
11
  #
@@ -40,7 +39,7 @@ module Bundler
40
39
  #
41
40
  # @param lockfile [Pathname] Path to Gemfile.lock
42
41
  # @param dependencies [Array(Bundler::Dependency)] array of dependencies from Gemfile
43
- # @param sources [Array(Bundler::Source::Rubygems)]
42
+ # @param sources [Bundler::SourceList]
44
43
  # @param unlock [Hash, Boolean, nil] Gems that have been requested
45
44
  # to be updated or true if all gems should be updated
46
45
  # @param ruby_version [Bundler::RubyVersion, nil] Requested Ruby Version
@@ -111,14 +110,14 @@ module Bundler
111
110
 
112
111
  def resolve_with_cache!
113
112
  raise "Specs already loaded" if @specs
114
- @sources.each { |s| s.cached! }
113
+ sources.cached!
115
114
  specs
116
115
  end
117
116
 
118
117
  def resolve_remotely!
119
118
  raise "Specs already loaded" if @specs
120
119
  @remote = true
121
- @sources.each { |s| s.remote! }
120
+ sources.remote!
122
121
  specs
123
122
  end
124
123
 
@@ -210,7 +209,7 @@ module Bundler
210
209
  dependency_names = @dependencies.dup || []
211
210
  dependency_names.map! {|d| d.name }
212
211
 
213
- @sources.each do |s|
212
+ sources.all_sources.each do |s|
214
213
  if s.is_a?(Bundler::Source::Rubygems)
215
214
  s.dependency_names = dependency_names.uniq
216
215
  idx.add_source s.specs
@@ -227,13 +226,22 @@ module Bundler
227
226
  # spec, even if (say) a git gem is not checked out.
228
227
  def rubygems_index
229
228
  @rubygems_index ||= Index.build do |idx|
230
- rubygems = @sources.find{|s| s.is_a?(Source::Rubygems) }
231
- idx.add_source rubygems.specs
229
+ sources.rubygems_sources.each do |rubygems|
230
+ idx.add_source rubygems.specs
231
+ end
232
232
  end
233
233
  end
234
234
 
235
- def rubygems_remotes
236
- @sources.select{|s| s.is_a?(Source::Rubygems) }.map{|s| s.remotes }.flatten
235
+ def has_rubygems_remotes?
236
+ sources.rubygems_sources.any? {|s| s.remotes.any? }
237
+ end
238
+
239
+ def has_local_dependencies?
240
+ !sources.path_sources.empty? || !sources.git_sources.empty?
241
+ end
242
+
243
+ def spec_git_paths
244
+ sources.git_sources.map {|s| s.path.to_s }
237
245
  end
238
246
 
239
247
  def groups
@@ -265,12 +273,12 @@ module Bundler
265
273
  def to_lock
266
274
  out = ""
267
275
 
268
- sorted_sources.each do |source|
276
+ sources.lock_sources.each do |source|
269
277
  # Add the source header
270
278
  out << source.to_lock
271
279
  # Find all specs for this source
272
280
  resolve.
273
- select { |s| s.source == source }.
281
+ select { |s| source.can_lock?(s) }.
274
282
  # This needs to be sorted by full name so that
275
283
  # gems with the same name, but different platform
276
284
  # are ordered consistently
@@ -319,9 +327,10 @@ module Bundler
319
327
  deleted = []
320
328
  changed = []
321
329
 
322
- if @locked_sources != @sources
323
- new_sources = @sources - @locked_sources
324
- deleted_sources = @locked_sources - @sources
330
+ gemfile_sources = sources.all_sources
331
+ if @locked_sources != gemfile_sources
332
+ new_sources = gemfile_sources - @locked_sources
333
+ deleted_sources = @locked_sources - gemfile_sources
325
334
 
326
335
  if new_sources.any?
327
336
  added.concat new_sources.map { |source| "* source: #{source}" }
@@ -393,6 +402,8 @@ module Bundler
393
402
 
394
403
  private
395
404
 
405
+ attr_reader :sources
406
+
396
407
  def nothing_changed?
397
408
  !@source_changes && !@dependency_changes && !@new_platform && !@path_changes && !@local_changes
398
409
  end
@@ -441,8 +452,7 @@ module Bundler
441
452
  end
442
453
 
443
454
  def converge_paths
444
- @sources.any? do |source|
445
- next unless source.instance_of?(Source::Path)
455
+ sources.path_sources.any? do |source|
446
456
  specs_changed?(source) do |ls|
447
457
  ls.class == source.class && ls.path == source.path
448
458
  end
@@ -453,26 +463,16 @@ module Bundler
453
463
  changes = false
454
464
 
455
465
  # Get the Rubygems source from the Gemfile.lock
456
- locked_gem = @locked_sources.find { |s| s.kind_of?(Source::Rubygems) }
457
-
458
- # Get the Rubygems source from the Gemfile
459
- actual_gem = @sources.find { |s| s.kind_of?(Source::Rubygems) }
460
-
461
- # If there is a Rubygems source in both
462
- if locked_gem && actual_gem
463
- # Merge the remotes from the Gemfile into the Gemfile.lock
464
- changes = changes | locked_gem.replace_remotes(actual_gem)
465
- end
466
+ locked_gem = @locked_sources.select { |s| s.kind_of?(Source::Rubygems) }
466
467
 
467
468
  # Replace the sources from the Gemfile with the sources from the Gemfile.lock,
468
469
  # if they exist in the Gemfile.lock and are `==`. If you can't find an equivalent
469
470
  # source in the Gemfile.lock, use the one from the Gemfile.
470
- @sources.map! do |source|
471
- @locked_sources.find { |s| s == source } || source
472
- end
473
- changes = changes | (Set.new(@sources) != Set.new(@locked_sources))
471
+ sources.replace_sources!(@locked_sources)
472
+ gemfile_sources = sources.all_sources
473
+ changes = changes | (Set.new(gemfile_sources) != Set.new(@locked_sources))
474
474
 
475
- @sources.each do |source|
475
+ gemfile_sources.each do |source|
476
476
  # If the source is unlockable and the current command allows an unlock of
477
477
  # the source (for example, you are doing a `bundle update <foo>` of a git-pinned
478
478
  # gem), unlock it. For git sources, this means to unlock the revision, which
@@ -490,7 +490,7 @@ module Bundler
490
490
  def converge_dependencies
491
491
  (@dependencies + @locked_deps).each do |dep|
492
492
  if dep.source
493
- dep.source = @sources.find { |s| dep.source == s }
493
+ dep.source = sources.get(dep.source)
494
494
  end
495
495
  end
496
496
  Set.new(@dependencies) != Set.new(@locked_deps)
@@ -524,7 +524,7 @@ module Bundler
524
524
 
525
525
  converged = []
526
526
  @locked_specs.each do |s|
527
- s.source = @sources.find { |src| s.source == src }
527
+ s.source = sources.get(s.source)
528
528
 
529
529
  # Don't add a spec to the list if its source is expired. For example,
530
530
  # if you change a Git gem to Rubygems.
@@ -553,7 +553,7 @@ module Bundler
553
553
  diff = @locked_specs.to_a - resolve.to_a
554
554
 
555
555
  # Now, we unlock any sources that do not have anymore gems pinned to it
556
- @sources.each do |source|
556
+ sources.all_sources.each do |source|
557
557
  next unless source.respond_to?(:unlock!)
558
558
 
559
559
  unless resolve.any? { |s| s.source == source }
@@ -588,13 +588,6 @@ module Bundler
588
588
  deps
589
589
  end
590
590
 
591
- def sorted_sources
592
- @sources.sort_by do |s|
593
- # Place GEM at the top
594
- [ s.is_a?(Source::Rubygems) ? 1 : 0, s.to_s ]
595
- end
596
- end
597
-
598
591
  def requested_dependencies
599
592
  groups = self.groups - Bundler.settings.without
600
593
  groups.map! { |g| g.to_sym }
@@ -17,7 +17,7 @@ module Bundler
17
17
 
18
18
  def initialize
19
19
  @source = nil
20
- @sources = []
20
+ @sources = SourceList.new
21
21
  @git_sources = {}
22
22
  @dependencies = []
23
23
  @groups = []
@@ -27,10 +27,6 @@ module Bundler
27
27
  add_github_sources
28
28
  end
29
29
 
30
- def rubygems_source
31
- @rubygems_source ||= Source::Rubygems.new
32
- end
33
-
34
30
  def eval_gemfile(gemfile, contents = nil)
35
31
  contents ||= Bundler.read_file(gemfile.to_s)
36
32
  instance_eval(contents, gemfile.to_s, 1)
@@ -70,12 +66,8 @@ module Bundler
70
66
  end
71
67
 
72
68
  def gem(name, *args)
73
- if name.is_a?(Symbol)
74
- raise GemfileError, %{You need to specify gem names as Strings. Use 'gem "#{name.to_s}"' instead.}
75
- end
76
-
77
69
  options = args.last.is_a?(Hash) ? args.pop.dup : {}
78
- version = args
70
+ version = args || [">= 0"]
79
71
 
80
72
  normalize_options(name, version, options)
81
73
 
@@ -115,37 +107,13 @@ module Bundler
115
107
  @dependencies << dep
116
108
  end
117
109
 
118
- def source(source, options = {})
119
- case source
120
- when :gemcutter, :rubygems, :rubyforge then
121
- Bundler.ui.warn "The source :#{source} is deprecated because HTTP " \
122
- "requests are insecure.\nPlease change your source to 'https://" \
123
- "rubygems.org' if possible, or 'http://rubygems.org' if not."
124
- rubygems_source.add_remote "http://rubygems.org"
125
- return
126
- when String
127
- rubygems_source.add_remote source
128
-
129
- if block_given?
130
- Bundler.ui.warn "A block was passed to `source`, but Bundler versions " \
131
- "prior to 1.7 ignore the block. Please upgrade Bundler to 1.7 or " \
132
- "specify your dependencies outside of the block passed to `source`."
133
- end
134
-
135
- return
110
+ def source(source, &blk)
111
+ source = normalize_source(source)
112
+ if block_given?
113
+ with_source(@sources.add_rubygems_source("remotes" => source), &blk)
136
114
  else
137
- @source = source
138
- if options[:prepend]
139
- @sources = [@source] | @sources
140
- else
141
- @sources = @sources | [@source]
142
- end
143
-
144
- yield if block_given?
145
- return @source
115
+ @sources.add_rubygems_remote(source)
146
116
  end
147
- ensure
148
- @source = nil
149
117
  end
150
118
 
151
119
  def git_source(name, &block)
@@ -161,11 +129,11 @@ module Bundler
161
129
  @git_sources[name.to_s] = block
162
130
  end
163
131
 
164
- def path(path, options = {}, source_options = {}, &blk)
165
- source Source::Path.new(normalize_hash(options).merge("path" => Pathname.new(path))), source_options, &blk
132
+ def path(path, options = {}, &blk)
133
+ with_source(@sources.add_path_source(normalize_hash(options).merge("path" => Pathname.new(path))), &blk)
166
134
  end
167
135
 
168
- def git(uri, options = {}, source_options = {}, &blk)
136
+ def git(uri, options = {}, &blk)
169
137
  unless block_given?
170
138
  msg = "You can no longer specify a git source by itself. Instead, \n" \
171
139
  "either use the :git option on a gem, or specify the gems that \n" \
@@ -177,11 +145,10 @@ module Bundler
177
145
  raise DeprecatedError, msg
178
146
  end
179
147
 
180
- source Source::Git.new(normalize_hash(options).merge("uri" => uri)), source_options, &blk
148
+ with_source(@sources.add_git_source(normalize_hash(options).merge("uri" => uri)), &blk)
181
149
  end
182
150
 
183
151
  def to_definition(lockfile, unlock)
184
- @sources << rubygems_source unless @sources.include?(rubygems_source)
185
152
  Definition.new(lockfile, @dependencies, @sources, unlock, @ruby_version)
186
153
  end
187
154
 
@@ -224,6 +191,16 @@ module Bundler
224
191
  git_source(:gist){ |repo_name| "https://gist.github.com/#{repo_name}.git" }
225
192
  end
226
193
 
194
+ def with_source(source)
195
+ if block_given?
196
+ @source = source
197
+ yield
198
+ end
199
+ source
200
+ ensure
201
+ @source = nil
202
+ end
203
+
227
204
  def normalize_hash(opts)
228
205
  opts.keys.each do |k|
229
206
  opts[k.to_s] = opts.delete(k) unless k.is_a?(String)
@@ -232,10 +209,14 @@ module Bundler
232
209
  end
233
210
 
234
211
  def valid_keys
235
- @valid_keys ||= %w(group groups git path name branch ref tag require submodules platform platforms type)
212
+ @valid_keys ||= %w(group groups git path name branch ref tag require submodules platform platforms type source)
236
213
  end
237
214
 
238
215
  def normalize_options(name, version, opts)
216
+ if name.is_a?(Symbol)
217
+ raise GemfileError, %{You need to specify gem names as Strings. Use 'gem "#{name.to_s}"' instead.}
218
+ end
219
+
239
220
  normalize_hash(opts)
240
221
 
241
222
  git_names = @git_sources.keys.map(&:to_s)
@@ -267,6 +248,12 @@ module Bundler
267
248
  raise GemfileError, "`#{p}` is not a valid platform. The available options are: #{VALID_PLATFORMS.inspect}"
268
249
  end
269
250
 
251
+ # Save sources passed in a key
252
+ if opts.has_key?("source")
253
+ source = normalize_source(opts["source"])
254
+ opts["source"] = @sources.add_rubygems_source("remotes" => source)
255
+ end
256
+
270
257
  git_name = (git_names & opts.keys).last
271
258
  if @git_sources[git_name]
272
259
  opts["git"] = @git_sources[git_name].call(opts[git_name])
@@ -279,7 +266,7 @@ module Bundler
279
266
  else
280
267
  options = opts.dup
281
268
  end
282
- source = send(type, param, options, :prepend => true) {}
269
+ source = send(type, param, options) {}
283
270
  opts["source"] = source
284
271
  end
285
272
  end
@@ -290,5 +277,18 @@ module Bundler
290
277
  opts["group"] = groups
291
278
  end
292
279
 
280
+ def normalize_source(source)
281
+ case source
282
+ when :gemcutter, :rubygems, :rubyforge
283
+ Bundler.ui.warn "The source :#{source} is deprecated because HTTP " \
284
+ "requests are insecure.\nPlease change your source to 'https://" \
285
+ "rubygems.org' if possible, or 'http://rubygems.org' if not."
286
+ "http://rubygems.org"
287
+ when String
288
+ source
289
+ else
290
+ raise GemfileError, "Unknown source '#{source}'"
291
+ end
292
+ end
293
293
  end
294
294
  end