Class: Bundler::Patch::DefinitionPrep

Inherits:
Object
  • Object
show all
Defined in:
lib/bundler/patch/conservative_definition.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(bundler_def, gem_patches, options) ⇒ DefinitionPrep

Returns a new instance of DefinitionPrep.



47
48
49
50
51
# File 'lib/bundler/patch/conservative_definition.rb', line 47

def initialize(bundler_def, gem_patches, options)
  @bundler_def = bundler_def
  @gems_to_update = GemsToUpdate.new(gem_patches, options)
  @options = options
end

Instance Attribute Details

#bundler_defObject (readonly)

Returns the value of attribute bundler_def.



45
46
47
# File 'lib/bundler/patch/conservative_definition.rb', line 45

def bundler_def
  @bundler_def
end

Instance Method Details

#fixup_empty_remotesObject

This may only matter in cases like sidekiq where the sidekiq-pro gem is served from their gem server and depends on the open-source sidekiq gem served from rubygems.org, and when patching those, without the appropriate remotes being set in rubygems_aggregrate, it won’t work.

I’ve seen some other weird cases where a remote source index had no entry for a gem and would trip up bundler-audit. I couldn’t pin them down at the time though. But I want to keep this in case.

The underlying issue in Bundler 1.10 appears to be when the Definition constructor receives ‘true` as the `unlock` parameter, then @locked_sources is initialized to empty array, and the related rubygems_aggregrate source instance ends up with no @remotes set in it, which I think happens during converge_sources. Without those set, then the index will list no gem versions in some cases. (It was complicated enough to discover this patch, I haven’t fully worked out the flaw, which still could be on my side of the fence).



79
80
81
82
83
# File 'lib/bundler/patch/conservative_definition.rb', line 79

def fixup_empty_remotes
  b_sources = @bundler_def.send(:sources)
  empty_remotes = b_sources.rubygems_sources.detect { |s| s.remotes.empty? }
  empty_remotes.remotes.push(*b_sources.rubygems_remotes) if empty_remotes
end

#prepObject



53
54
55
56
57
58
59
60
61
# File 'lib/bundler/patch/conservative_definition.rb', line 53

def prep
  @bundler_def ||= Bundler.definition(@gems_to_update.to_bundler_definition)
  @bundler_def.extend ConservativeDefinition
  @bundler_def.gems_to_update = @gems_to_update
  @bundler_def.strict = @options[:strict]
  @bundler_def.minor_allowed = @options[:minor_allowed]
  fixup_empty_remotes if @gems_to_update.to_bundler_definition === true
  @bundler_def
end