Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[VersionConflict] Allow customizing incompatible_version_message_for_conflict #99

Merged
merged 3 commits into from
Aug 7, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

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