Skip to content

Commit

Permalink
Merge pull request #99 from CocoaPods/segiddins/customize-incompatibl…
Browse files Browse the repository at this point in the history
…e-message

[VersionConflict] Allow customizing incompatible_version_message_for_conflict
  • Loading branch information
segiddins authored Aug 7, 2018
2 parents 19c196e + 70f72d1 commit 1ea466a
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 22 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
* Improve performance of `Vertex#path_to?`.
[Samuel Giddins](https://github.com/segiddins)

* Allow customization of string used to say that a version conflict has occurred
for a particular name by passing in the `:incompatible_version_message_for_conflict`
key when constructing a version conflict message with trees.
[Samuel Giddins](https://github.com/segiddins)

##### Bug Fixes

* None.
Expand Down
44 changes: 23 additions & 21 deletions Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -52,29 +52,31 @@ begin

files = FileList['lib/**/*.rb']

out, err = Open3.popen3('ruby', '-w', '-Ilib') do |stdin, stdout, stderr, _wait_thr|
files.each do |file|
stdin.puts "require '#{file.gsub(%r{(^lib/|\.rb$)}, '')}'"
end
stdin.close

[stdout, stderr].map do |io|
chunk_size = 16_384
select_timeout = 0.02
buffer = []
next '' if io.closed? || io.eof?
# IO.select cannot be used here due to the fact that it
# just does not work on windows
loop do
begin
IO.select([io], nil, nil, select_timeout)
break if io.eof? # stop raising :-(
buffer << io.readpartial(chunk_size)
rescue EOFError
break
out, err = Bundler.with_original_env do
Open3.popen3(Gem.ruby, '-w', '-Ilib') do |stdin, stdout, stderr, _wait_thr|
files.each do |file|
stdin.puts "require '#{file.gsub(%r{(^lib/|\.rb$)}, '')}'"
end
stdin.close

[stdout, stderr].map do |io|
chunk_size = 16_384
select_timeout = 0.02
buffer = []
next '' if io.closed? || io.eof?
# IO.select cannot be used here due to the fact that it
# just does not work on windows
loop do
begin
IO.select([io], nil, nil, select_timeout)
break if io.eof? # stop raising :-(
buffer << io.readpartial(chunk_size)
rescue EOFError
break
end
end
buffer.join.strip
end
buffer.join.strip
end
end

Expand Down
7 changes: 6 additions & 1 deletion lib/molinillo/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,14 @@ def message_with_trees(opts = {})
printable_requirement = opts.delete(:printable_requirement) { proc { |req| req.to_s } }
additional_message_for_conflict = opts.delete(:additional_message_for_conflict) { proc {} }
version_for_spec = opts.delete(:version_for_spec) { proc(&:to_s) }
incompatible_version_message_for_conflict = opts.delete(:incompatible_version_message_for_conflict) do
proc do |name, _conflict|
%(#{solver_name} could not find compatible versions for #{possibility_type} "#{name}":)
end
end

conflicts.sort.reduce(''.dup) do |o, (name, conflict)|
o << %(\n#{solver_name} could not find compatible versions for #{possibility_type} "#{name}":\n)
o << "\n" << incompatible_version_message_for_conflict.call(name, conflict) << "\n"
if conflict.locked_requirement
o << %( In snapshot (#{name_for_locking_dependency_source}):\n)
o << %( #{printable_requirement.call(conflict.locked_requirement)}\n)
Expand Down

0 comments on commit 1ea466a

Please sign in to comment.