diff options
| author | Mike McQuaid | 2014-10-16 13:01:48 +0100 | 
|---|---|---|
| committer | Mike McQuaid | 2014-10-19 13:58:52 +0100 | 
| commit | b805444ed0a4f0e89b81975a69ae1267407c24fc (patch) | |
| tree | dfe5e072e3ea6f66bb844762d944c611199870f2 | |
| parent | d9afeee9c37df7d70847cc7452f9c0fc30fc60eb (diff) | |
| download | homebrew-b805444ed0a4f0e89b81975a69ae1267407c24fc.tar.bz2 | |
tab: remap deprecated options in tabs.
If a deprecated option is found in a tab, rename it to the new option.
| -rw-r--r-- | Library/Homebrew/tab.rb | 15 | ||||
| -rw-r--r-- | Library/Homebrew/test/test_tab.rb | 7 | 
2 files changed, 21 insertions, 1 deletions
diff --git a/Library/Homebrew/tab.rb b/Library/Homebrew/tab.rb index 96639fb20..29836365b 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 37a2cc06f..bb4ea9198 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  | 
