From 309e9e1c52d629049649b743b751eeb75d8d1887 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Tue, 11 May 2021 15:44:05 -0400 Subject: [PATCH] Remove `Keg::Relocation#start_with_old_value?` method --- Library/Homebrew/extend/os/mac/keg_relocate.rb | 5 +++-- Library/Homebrew/keg_relocate.rb | 4 ---- Library/Homebrew/test/keg_relocate/relocation_spec.rb | 11 ----------- 3 files changed, 3 insertions(+), 17 deletions(-) diff --git a/Library/Homebrew/extend/os/mac/keg_relocate.rb b/Library/Homebrew/extend/os/mac/keg_relocate.rb index 4766230315..1993dcccf0 100644 --- a/Library/Homebrew/extend/os/mac/keg_relocate.rb +++ b/Library/Homebrew/extend/os/mac/keg_relocate.rb @@ -131,9 +131,10 @@ class Keg old_prefix, new_prefix = relocation.replacement_pair_for(:prefix) old_cellar, new_cellar = relocation.replacement_pair_for(:cellar) - if relocation.start_with_old_value? :cellar, old_name + case old_name + when /^#{old_cellar}/ old_name.sub(old_cellar, new_cellar) - elsif relocation.start_with_old_value? :prefix, old_name + when /^#{old_prefix}/ old_name.sub(old_prefix, new_prefix) end end diff --git a/Library/Homebrew/keg_relocate.rb b/Library/Homebrew/keg_relocate.rb index 759f526ff6..5c85626844 100644 --- a/Library/Homebrew/keg_relocate.rb +++ b/Library/Homebrew/keg_relocate.rb @@ -33,10 +33,6 @@ class Keg @replacement_map.fetch(key) end - def start_with_old_value?(key, text) - text.match?(/^#{@replacement_map.fetch(key).first}/) - end - sig { params(text: String).void } def replace_text(text) replacements = @replacement_map.values.to_h diff --git a/Library/Homebrew/test/keg_relocate/relocation_spec.rb b/Library/Homebrew/test/keg_relocate/relocation_spec.rb index 503aa3dd14..ff0838c907 100644 --- a/Library/Homebrew/test/keg_relocate/relocation_spec.rb +++ b/Library/Homebrew/test/keg_relocate/relocation_spec.rb @@ -59,17 +59,6 @@ describe Keg::Relocation do REPLACED end - specify "#start_with_old_value?" do - relocation = setup_relocation - - expect(relocation.start_with_old_value?(:prefix, "#{HOMEBREW_PREFIX}/foo")).to be true - expect(relocation.start_with_old_value?(:prefix, "foo#{HOMEBREW_PREFIX}/bar")).to be false - expect(relocation.start_with_old_value?(:cellar, "#{HOMEBREW_CELLAR}/foo")).to be true - expect(relocation.start_with_old_value?(:cellar, "foo#{HOMEBREW_CELLAR}/bar")).to be false - expect(relocation.start_with_old_value?(:repository_placeholder, "@@HOMEBREW_REPOSITORY@@/foo")).to be true - expect(relocation.start_with_old_value?(:library_placeholder, "foo@@HOMEBREW_LIBRARY@@/bar")).to be false - end - specify "::path_regex" do expect(described_class.path_regex(prefix)).to eq escaped_prefix expect(described_class.path_regex("foo.bar")).to eq(/(?