bundler 4.1.0.beta1 → 4.1.0.beta2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (50) hide show
  1. checksums.yaml +4 -4
  2. data/lib/bundler/build_metadata.rb +2 -2
  3. data/lib/bundler/cli/common.rb +4 -0
  4. data/lib/bundler/cli/doctor/ssl.rb +4 -8
  5. data/lib/bundler/cli/info.rb +1 -1
  6. data/lib/bundler/cli/lock.rb +14 -3
  7. data/lib/bundler/cli/open.rb +7 -1
  8. data/lib/bundler/cli/outdated.rb +8 -10
  9. data/lib/bundler/cli/platform.rb +15 -1
  10. data/lib/bundler/cli/show.rb +5 -1
  11. data/lib/bundler/cli/update.rb +1 -1
  12. data/lib/bundler/cli.rb +22 -7
  13. data/lib/bundler/constants.rb +1 -1
  14. data/lib/bundler/definition.rb +64 -14
  15. data/lib/bundler/dsl.rb +61 -3
  16. data/lib/bundler/fetcher/downloader.rb +5 -1
  17. data/lib/bundler/gem_helper.rb +1 -1
  18. data/lib/bundler/installer/parallel_installer.rb +2 -1
  19. data/lib/bundler/installer.rb +5 -1
  20. data/lib/bundler/lazy_specification.rb +1 -1
  21. data/lib/bundler/lockfile_parser.rb +1 -1
  22. data/lib/bundler/man/bundle-info.1 +4 -1
  23. data/lib/bundler/man/bundle-info.1.ronn +4 -0
  24. data/lib/bundler/man/bundle-lock.1 +2 -2
  25. data/lib/bundler/man/bundle-lock.1.ronn +4 -3
  26. data/lib/bundler/man/bundle-open.1 +4 -1
  27. data/lib/bundler/man/bundle-open.1.ronn +4 -1
  28. data/lib/bundler/man/bundle-outdated.1 +1 -1
  29. data/lib/bundler/man/bundle-outdated.1.ronn +1 -1
  30. data/lib/bundler/man/bundle-show.1 +4 -1
  31. data/lib/bundler/man/bundle-show.1.ronn +4 -0
  32. data/lib/bundler/man/bundle-update.1 +3 -3
  33. data/lib/bundler/man/bundle-update.1.ronn +5 -3
  34. data/lib/bundler/man/gemfile.5 +33 -1
  35. data/lib/bundler/man/gemfile.5.ronn +53 -2
  36. data/lib/bundler/materialization.rb +3 -1
  37. data/lib/bundler/override.rb +30 -2
  38. data/lib/bundler/resolver.rb +28 -4
  39. data/lib/bundler/self_manager.rb +15 -9
  40. data/lib/bundler/settings.rb +10 -26
  41. data/lib/bundler/source/git/git_proxy.rb +39 -2
  42. data/lib/bundler/source/git.rb +34 -7
  43. data/lib/bundler/source/rubygems_aggregate.rb +1 -1
  44. data/lib/bundler/source_map.rb +7 -3
  45. data/lib/bundler/spec_set.rb +8 -4
  46. data/lib/bundler/templates/newgem/ext/newgem/Cargo.toml.tt +1 -1
  47. data/lib/bundler/version.rb +1 -1
  48. data/lib/bundler.rb +1 -3
  49. data/lib/rubygems/compact_index_client/http_fetcher.rb +5 -3
  50. metadata +391 -390
@@ -7,12 +7,13 @@ module Bundler
7
7
  class Git < Path
8
8
  autoload :GitProxy, File.expand_path("git/git_proxy", __dir__)
9
9
 
10
- attr_reader :uri, :ref, :branch, :options, :glob, :submodules
10
+ attr_reader :uri, :ref, :branch, :options, :glob, :submodules, :sparse_checkout
11
11
 
12
12
  def initialize(options)
13
13
  @options = options
14
14
  @checksum_store = Checksum::Store.new
15
- @glob = options["glob"] || DEFAULT_GLOB
15
+ @sparse_checkout = normalize_sparse_checkout(options)
16
+ @glob = options["glob"] || sparse_checkout_glob || DEFAULT_GLOB
16
17
 
17
18
  @allow_cached = false
18
19
  @allow_remote = false
@@ -58,12 +59,13 @@ module Bundler
58
59
  %w[ref branch tag submodules].each do |opt|
59
60
  out << " #{opt}: #{options[opt]}\n" if options[opt]
60
61
  end
62
+ @sparse_checkout&.each {|dir| out << " sparse_checkout: #{dir}\n" }
61
63
  out << " glob: #{@glob}\n" unless default_glob?
62
64
  out << " specs:\n"
63
65
  end
64
66
 
65
67
  def to_gemfile
66
- specifiers = %w[ref branch tag submodules glob].map do |opt|
68
+ specifiers = %w[ref branch tag submodules glob sparse_checkout].map do |opt|
67
69
  "#{opt}: #{options[opt]}" if options[opt]
68
70
  end
69
71
 
@@ -71,14 +73,15 @@ module Bundler
71
73
  end
72
74
 
73
75
  def hash
74
- [self.class, uri, ref, branch, name, glob, submodules].hash
76
+ [self.class, uri, ref, branch, name, glob, submodules, sparse_checkout].hash
75
77
  end
76
78
 
77
79
  def eql?(other)
78
80
  other.is_a?(Git) && uri == other.uri && ref == other.ref &&
79
81
  branch == other.branch && name == other.name &&
80
82
  glob == other.glob &&
81
- submodules == other.submodules
83
+ submodules == other.submodules &&
84
+ sparse_checkout == other.sparse_checkout
82
85
  end
83
86
 
84
87
  alias_method :==, :eql?
@@ -87,7 +90,8 @@ module Bundler
87
90
  other.is_a?(Git) && uri == other.uri &&
88
91
  name == other.name &&
89
92
  glob == other.glob &&
90
- submodules == other.submodules
93
+ submodules == other.submodules &&
94
+ sparse_checkout == other.sparse_checkout
91
95
  end
92
96
 
93
97
  def to_s
@@ -389,7 +393,30 @@ module Bundler
389
393
  end
390
394
 
391
395
  def shortref_for_path(ref)
392
- ref[0..11]
396
+ shortref = ref[0..11]
397
+ return shortref unless @sparse_checkout
398
+
399
+ # Checkouts of the same revision with different cones hold different files
400
+ "#{shortref}-#{Bundler::Digest.sha1(@sparse_checkout.join("\n"))[0..7]}"
401
+ end
402
+
403
+ def normalize_sparse_checkout(options)
404
+ return unless options["sparse_checkout"]
405
+
406
+ dirs = Array(options["sparse_checkout"])
407
+ unless dirs.any? && dirs.all? {|dir| dir.is_a?(String) && !dir.empty? }
408
+ raise GemfileError, "The :sparse_checkout option must be a directory or an array of directories, " \
409
+ "but #{options["sparse_checkout"].inspect} was given"
410
+ end
411
+
412
+ options["sparse_checkout"] = dirs
413
+ end
414
+
415
+ def sparse_checkout_glob
416
+ return unless @sparse_checkout
417
+
418
+ dirs = @sparse_checkout.size == 1 ? @sparse_checkout.first : "{#{@sparse_checkout.join(",")}}"
419
+ "#{dirs}/#{DEFAULT_GLOB}"
393
420
  end
394
421
 
395
422
  def glob_for_display
@@ -29,7 +29,7 @@ module Bundler
29
29
 
30
30
  def build_index
31
31
  Index.build do |idx|
32
- dependency_names = source_map.pinned_spec_names
32
+ dependency_names = source_map.pinned_spec_names | source_map.replacement_names
33
33
 
34
34
  sources.all_sources.each do |source|
35
35
  next if @excluded_sources.include?(source)
@@ -2,12 +2,15 @@
2
2
 
3
3
  module Bundler
4
4
  class SourceMap
5
- attr_reader :sources, :dependencies, :locked_specs
5
+ attr_reader :sources, :dependencies, :locked_specs, :replacement_names
6
6
 
7
- def initialize(sources, dependencies, locked_specs)
7
+ def initialize(sources, dependencies, locked_specs, replacement_names = [])
8
8
  @sources = sources
9
9
  @dependencies = dependencies
10
10
  @locked_specs = locked_specs
11
+ # No gemspec names a gem that a `from:`/`to:` override substitutes, so
12
+ # the dependency API never fetches it unless asked.
13
+ @replacement_names = replacement_names
11
14
  end
12
15
 
13
16
  def pinned_spec_names(skip = nil)
@@ -22,6 +25,7 @@ module Bundler
22
25
  end
23
26
 
24
27
  unmet_deps = explicit_sources.map do |source|
28
+ source.add_dependency_names(replacement_names)
25
29
  (source.spec_names - pinned_spec_names).each do |indirect_dependency_name|
26
30
  previous_source = requirements[indirect_dependency_name]
27
31
  if previous_source.nil?
@@ -39,7 +43,7 @@ module Bundler
39
43
  source.unmet_deps
40
44
  end
41
45
 
42
- sources.default_source.add_dependency_names(unmet_deps.flatten - requirements.keys)
46
+ sources.default_source.add_dependency_names(unmet_deps.flatten + replacement_names - requirements.keys)
43
47
 
44
48
  requirements
45
49
  end
@@ -84,11 +84,14 @@ module Bundler
84
84
  platforms.delete(Bundler.local_platform) if less_specific_platform
85
85
  end
86
86
 
87
- def validate_deps(s)
88
- s.runtime_dependencies.each do |dep|
87
+ def validate_deps(s, overrides = s.is_a?(LazySpecification) ? Array(s.overrides) : [])
88
+ Override.rewrite_dependencies(overrides, s.name, s.runtime_dependencies).each do |dep|
89
89
  next if dep.name == "bundler"
90
90
 
91
91
  return :missing unless names.include?(dep.name)
92
+
93
+ override = Override.find_for(overrides, dep.name, :version)
94
+ dep = Gem::Dependency.new(dep.name, override.apply_to(dep.requirement)) if override
92
95
  return :invalid if none? {|spec| dep.matches_spec?(spec) }
93
96
  end
94
97
 
@@ -281,7 +284,7 @@ module Bundler
281
284
  overrides = spec.is_a?(LazySpecification) ? Array(spec.overrides) : []
282
285
  matching_specs = spec.source.specs.search([spec.name, spec.version])
283
286
  platform_spec = MatchPlatform.select_best_platform_match(matching_specs, platform).find do |s|
284
- s.matches_current_metadata_with_overrides?(overrides) && valid_dependencies?(s)
287
+ s.matches_current_metadata_with_overrides?(overrides) && validate_deps(s, overrides) == :valid
285
288
  end
286
289
 
287
290
  if platform_spec
@@ -354,7 +357,8 @@ module Bundler
354
357
  end
355
358
 
356
359
  def tsort_each_child(s)
357
- s.dependencies.sort_by(&:name).each do |d|
360
+ dependencies = s.is_a?(LazySpecification) ? Override.rewrite_dependencies(s.overrides, s.name, s.dependencies) : s.dependencies
361
+ dependencies.sort_by(&:name).each do |d|
358
362
  next if d.type == :development
359
363
 
360
364
  specs_for_name = lookup[d.name]
@@ -12,7 +12,7 @@ publish = false
12
12
  crate-type = ["cdylib"]
13
13
 
14
14
  [dependencies]
15
- magnus = { version = "0.8.2" }
15
+ magnus = { version = "0.9" }
16
16
  rb-sys = { version = "0.9", features = ["stable-api-compiled-fallback"] }
17
17
 
18
18
  [build-dependencies]
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: false
2
2
 
3
3
  module Bundler
4
- VERSION = "4.1.0.beta1".freeze
4
+ VERSION = "4.1.0.beta2".freeze
5
5
 
6
6
  def self.bundler_major_version
7
7
  @bundler_major_version ||= gem_version.segments.first
data/lib/bundler.rb CHANGED
@@ -119,9 +119,7 @@ module Bundler
119
119
  def bin_path
120
120
  @bin_path ||= begin
121
121
  path = Bundler.settings[:bin] || "bin"
122
- path = Pathname.new(path).expand_path(root).expand_path
123
- mkdir_p(path)
124
- path
122
+ Pathname.new(path).expand_path(root).expand_path
125
123
  end
126
124
  end
127
125
 
@@ -48,9 +48,11 @@ class Gem::CompactIndexClient
48
48
  if https?(uri) && !https?(redirect)
49
49
  raise Gem::RemoteFetcher::FetchError.new("redirecting to non-https resource: #{Gem::Uri.redact(redirect)}", uri)
50
50
  end
51
- # An absolute Location on the same host drops the credentials that a
52
- # relative one would have kept.
53
- redirect.userinfo = uri.userinfo if redirect.host == uri.host && !redirect.userinfo
51
+ # An absolute Location on the same origin drops the credentials that a
52
+ # relative one would have kept. Another port or scheme on the same host
53
+ # is a different protection space (RFC 9110, Section 11.5).
54
+ same_origin = [redirect.scheme, redirect.host, redirect.port] == [uri.scheme, uri.host, uri.port]
55
+ redirect.userinfo = uri.userinfo if same_origin && !redirect.userinfo
54
56
 
55
57
  fetch(redirect, headers, redirects_remaining - 1)
56
58
  when Gem::Net::HTTPRangeNotSatisfiable