From 31ce953f6911f9ad2e64311b9e0237f448ff3559 Mon Sep 17 00:00:00 2001 From: John Hawkinson Date: Sun, 9 Apr 2017 11:02:05 -0400 Subject: [PATCH 1/5] formula: conflicts_with doc: give realistic :because The documentation should help a developer understand what the parameter is for. "stupid example" doesn't cut it. --- Library/Homebrew/formula.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 523de244df..d544bd6687 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2340,7 +2340,7 @@ class Formula end # If this formula conflicts with another one. - #
conflicts_with "imagemagick", :because => "because this is just a stupid example"
+ #
conflicts_with "imagemagick", :because => "because both install 'convert' binaries"
def conflicts_with(*names) opts = names.last.is_a?(Hash) ? names.pop : {} names.each { |name| conflicts << FormulaConflict.new(name, opts[:because]) } From 971e53c001c06c66fab961c69951fa6c15459054 Mon Sep 17 00:00:00 2001 From: John Hawkinson Date: Sun, 9 Apr 2017 15:23:53 -0400 Subject: [PATCH 2/5] info: Print reason for conflicts where available --- Library/Homebrew/cmd/info.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index e7ad6821d1..da82632870 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -123,8 +123,12 @@ module Homebrew puts f.desc if f.desc puts Formatter.url(f.homepage) if f.homepage - conflicts = f.conflicts.map(&:name).sort! - puts "Conflicts with: #{conflicts*", "}" unless conflicts.empty? + conflicts = f.conflicts.map{ |f| + f.name + + if f.reason then " (because #{f.reason})" else "" end + }.sort! + msg="Conflicts with: " + puts msg+conflicts*(",\n"+" "*msg.length) unless conflicts.empty? kegs = f.installed_kegs.sort_by(&:version) if kegs.empty? From b0d25d83fef80cb655823746450e04820bb0fb31 Mon Sep 17 00:00:00 2001 From: John Hawkinson Date: Sun, 9 Apr 2017 17:14:09 -0400 Subject: [PATCH 3/5] info: rubocop --- Library/Homebrew/cmd/info.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index da82632870..60c8a28d29 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -123,10 +123,10 @@ module Homebrew puts f.desc if f.desc puts Formatter.url(f.homepage) if f.homepage - conflicts = f.conflicts.map{ |f| - f.name + - if f.reason then " (because #{f.reason})" else "" end - }.sort! + conflicts = f.conflicts.map do |c| + c.name + + (c.reason ? " (because #{c.reason})" : "") + end.sort! msg="Conflicts with: " puts msg+conflicts*(",\n"+" "*msg.length) unless conflicts.empty? From 33d4c95a287060d93200773a52443a1662846165 Mon Sep 17 00:00:00 2001 From: John Hawkinson Date: Sun, 14 May 2017 15:09:01 -0400 Subject: [PATCH 4/5] info: use more string interpolation --- Library/Homebrew/cmd/info.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index 60c8a28d29..613677761e 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -124,8 +124,8 @@ module Homebrew puts Formatter.url(f.homepage) if f.homepage conflicts = f.conflicts.map do |c| - c.name + - (c.reason ? " (because #{c.reason})" : "") + reason = " (because #{c.reason})" if c.reason + "#{c.name}#{reason}" end.sort! msg="Conflicts with: " puts msg+conflicts*(",\n"+" "*msg.length) unless conflicts.empty? From 8e2198ff018548df6aa0854f22a111bacee081a7 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Mon, 15 May 2017 10:40:07 +0100 Subject: [PATCH 5/5] info: tweak conflicts output code. --- Library/Homebrew/cmd/info.rb | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index 613677761e..ba920d005b 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -127,8 +127,12 @@ module Homebrew reason = " (because #{c.reason})" if c.reason "#{c.name}#{reason}" end.sort! - msg="Conflicts with: " - puts msg+conflicts*(",\n"+" "*msg.length) unless conflicts.empty? + unless conflicts.empty? + puts <<-EOS.undent + Conflicts with: + #{conflicts.join(" \n")} + EOS + end kegs = f.installed_kegs.sort_by(&:version) if kegs.empty?