diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 96639fb208..29836365b9 100644 --- a/Library/Homebrew/tab.rb +++ b/Library/Homebrew/tab.rb @@ -43,6 +43,16 @@ class Tab < OpenStruct for_formula(Formulary.factory(name)) end + def self.remap_deprecated_options deprecated_options, options + deprecated_options.each do |deprecated_option| + option = options.find {|option| option.name == deprecated_option.old } + next unless option + options -= [option] + options << Option.new(deprecated_option.current, option.description) + end + options + end + def self.for_formula f paths = [] @@ -63,7 +73,10 @@ class Tab < OpenStruct path = paths.map { |pn| pn.join(FILENAME) }.find(&:file?) if path - from_file(path) + tab = from_file(path) + used_options = remap_deprecated_options(f.deprecated_options, tab.used_options) + tab.used_options = used_options.as_flags + tab else dummy_tab(f) end diff --git a/Library/Homebrew/test/test_tab.rb b/Library/Homebrew/test/test_tab.rb index 37a2cc06f6..bb4ea9198d 100644 --- a/Library/Homebrew/test/test_tab.rb +++ b/Library/Homebrew/test/test_tab.rb @@ -90,6 +90,13 @@ class TabTests < Homebrew::TestCase assert_equal @tab.compiler, tab.compiler assert_equal @tab.stdlib, tab.stdlib end + + def test_remap_deprecated_options + deprecated_options = [DeprecatedOption.new("with-foo", "with-foo-new")] + remapped_options = Tab.remap_deprecated_options(deprecated_options, @tab.used_options) + assert_includes remapped_options, Option.new("without-bar") + assert_includes remapped_options, Option.new("with-foo-new") + end end class TabLoadingTests < Homebrew::TestCase