diff options
| author | Mike McQuaid | 2014-10-16 13:01:48 +0100 |
|---|---|---|
| committer | Mike McQuaid | 2014-10-19 13:58:52 +0100 |
| commit | 33b344962110794d268ee43c396624e4d2678ea3 (patch) | |
| tree | ffa3e20fb46679ce8a4efefb34e097bac447a012 /Library | |
| parent | d0240e7cd49a2dfa1f2bf39e307e4b55e663f762 (diff) | |
| download | brew-33b344962110794d268ee43c396624e4d2678ea3.tar.bz2 | |
tab: remap deprecated options in tabs.
If a deprecated option is found in a tab, rename it to the new option.
Diffstat (limited to 'Library')
| -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 |
