diff --git a/Library/Homebrew/cleanup.rb b/Library/Homebrew/cleanup.rb index 480a9c9ca1623..3003de496b077 100644 --- a/Library/Homebrew/cleanup.rb +++ b/Library/Homebrew/cleanup.rb @@ -84,7 +84,7 @@ def stale_formula?(scrub) return true end - return true if scrub && !formula.installed? + return true if scrub && !formula.latest_version_installed? return true if Utils::Bottles.file_outdated?(formula, self) diff --git a/Library/Homebrew/cli/args.rb b/Library/Homebrew/cli/args.rb index 202b5557db071..b8b35b36e4b82 100644 --- a/Library/Homebrew/cli/args.rb +++ b/Library/Homebrew/cli/args.rb @@ -84,11 +84,7 @@ def formulae require "formula" @formulae ||= (downcased_unique_named - casks).map do |name| - if name.include?("/") || File.exist?(name) - Formulary.factory(name, spec) - else - Formulary.find_with_priority(name, spec) - end + Formulary.factory(name, spec) end.uniq(&:name).freeze end diff --git a/Library/Homebrew/cli/parser.rb b/Library/Homebrew/cli/parser.rb index 53efc0058409f..5486f464b8bd5 100644 --- a/Library/Homebrew/cli/parser.rb +++ b/Library/Homebrew/cli/parser.rb @@ -359,11 +359,7 @@ def formulae named_args.map do |arg| next if arg.match?(HOMEBREW_CASK_TAP_CASK_REGEX) - if arg.include?("/") || arg.end_with?(".tar.gz") || File.exist?(arg) - Formulary.factory(arg, spec) - else - Formulary.find_with_priority(arg.downcase, spec) - end + Formulary.factory(arg, spec) end.compact.uniq(&:name) end end diff --git a/Library/Homebrew/cmd/--env.rb b/Library/Homebrew/cmd/--env.rb index 694b43207806b..a0c16eaafcd4c 100644 --- a/Library/Homebrew/cmd/--env.rb +++ b/Library/Homebrew/cmd/--env.rb @@ -36,7 +36,6 @@ def __env shell = if args.plain? nil elsif args.shell.nil? - # legacy behavior :bash unless $stdout.tty? elsif args.shell == "auto" Utils::Shell.parent || Utils::Shell.preferred diff --git a/Library/Homebrew/cmd/info.rb b/Library/Homebrew/cmd/info.rb index d914eb4977f2d..84873032359ba 100644 --- a/Library/Homebrew/cmd/info.rb +++ b/Library/Homebrew/cmd/info.rb @@ -105,11 +105,7 @@ def print_info args.named.each_with_index do |f, i| puts unless i.zero? begin - formula = if f.include?("/") || File.exist?(f) - Formulary.factory(f) - else - Formulary.find_with_priority(f) - end + Formulary.factory(f) if args.analytics? Utils::Analytics.formula_output(formula) else diff --git a/Library/Homebrew/cmd/tap-pin.rb b/Library/Homebrew/cmd/tap-pin.rb deleted file mode 100644 index b8e7a87365eeb..0000000000000 --- a/Library/Homebrew/cmd/tap-pin.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -require "cli/parser" - -module Homebrew - module_function - - def tap_pin_args - Homebrew::CLI::Parser.new do - hide_from_man_page! - end - end - - def tap_pin - odisabled "the brew tap-pin command", - "fully-scoped user/tap/formula naming when installing and in dependency references" - end -end diff --git a/Library/Homebrew/cmd/tap-unpin.rb b/Library/Homebrew/cmd/tap-unpin.rb deleted file mode 100644 index 2ec6e681a9096..0000000000000 --- a/Library/Homebrew/cmd/tap-unpin.rb +++ /dev/null @@ -1,18 +0,0 @@ -# frozen_string_literal: true - -require "cli/parser" - -module Homebrew - module_function - - def tap_unpin_args - Homebrew::CLI::Parser.new do - hide_from_man_page! - end - end - - def tap_unpin - odisabled "the brew tap-unpin command", - "fully-scoped user/tap/formula naming when installing and in dependency references" - end -end diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index df2481fb10f09..c1bf4ab05b9fb 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -216,7 +216,7 @@ def upgrade_formula(f) ensure # restore previous installation state if build failed begin - linked_kegs.each(&:link) unless f.installed? + linked_kegs.each(&:link) unless f.latest_version_installed? rescue nil end diff --git a/Library/Homebrew/compat.rb b/Library/Homebrew/compat.rb index a73aa184ef64c..79806737a5927 100644 --- a/Library/Homebrew/compat.rb +++ b/Library/Homebrew/compat.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true -require "compat/cask/dsl/version" -require "compat/language/python" -require "compat/requirements/macos_requirement" +require "compat/extend/nil" +require "compat/extend/string" require "compat/formula" +require "compat/language/python" require "compat/os/mac" if OS.mac? diff --git a/Library/Homebrew/compat/cask/dsl/version.rb b/Library/Homebrew/compat/cask/dsl/version.rb deleted file mode 100644 index d2b4aa94cfb23..0000000000000 --- a/Library/Homebrew/compat/cask/dsl/version.rb +++ /dev/null @@ -1,23 +0,0 @@ -# frozen_string_literal: true - -module Cask - class DSL - class Version < ::String - module Compat - def dots_to_slashes - odisabled "#dots_to_slashes" - end - - def hyphens_to_slashes - odisabled "#hyphens_to_slashes" - end - - def underscores_to_slashes - odisabled "#underscores_to_slashes" - end - end - - prepend Compat - end - end -end diff --git a/Library/Homebrew/compat/extend/nil.rb b/Library/Homebrew/compat/extend/nil.rb new file mode 100644 index 0000000000000..0fa14795588dc --- /dev/null +++ b/Library/Homebrew/compat/extend/nil.rb @@ -0,0 +1,11 @@ +# frozen_string_literal: true + +class NilClass + module Compat + def chuzzle + odeprecated "chuzzle", "chomp.presence" + end + end + + prepend Compat +end diff --git a/Library/Homebrew/compat/extend/string.rb b/Library/Homebrew/compat/extend/string.rb new file mode 100644 index 0000000000000..78baab5073ab0 --- /dev/null +++ b/Library/Homebrew/compat/extend/string.rb @@ -0,0 +1,15 @@ +# frozen_string_literal: true + +class String + module Compat + # String.chomp, but if result is empty: returns nil instead. + # Allows `chuzzle || foo` short-circuits. + def chuzzle + odeprecated "chuzzle", "chomp.presence" + s = chomp + s unless s.empty? + end + end + + prepend Compat +end diff --git a/Library/Homebrew/compat/formula.rb b/Library/Homebrew/compat/formula.rb index 66a6f8befb268..74caf081fbe43 100644 --- a/Library/Homebrew/compat/formula.rb +++ b/Library/Homebrew/compat/formula.rb @@ -3,10 +3,19 @@ class Formula module Compat def installed? - # odeprecated "Formula#installed?", - # "Formula#latest_version_installed? (or Formula#any_version_installed? )" + odeprecated "Formula#installed?", + "Formula#latest_version_installed? (or Formula#any_version_installed? )" latest_version_installed? end + + def prepare_patches + if respond_to?(:patches) + active_spec.add_legacy_patches(patches) + odeprecated "patches", "patch do" + end + + super + end end prepend Compat diff --git a/Library/Homebrew/compat/language/haskell.rb b/Library/Homebrew/compat/language/haskell.rb index 0f961b1c347ab..bea5f40de9be8 100644 --- a/Library/Homebrew/compat/language/haskell.rb +++ b/Library/Homebrew/compat/language/haskell.rb @@ -5,7 +5,7 @@ module Haskell module Cabal module Compat def cabal_sandbox(options = {}) - # odeprecated "Language::Haskell::Cabal.cabal_sandbox" + odeprecated "Language::Haskell::Cabal.cabal_sandbox" pwd = Pathname.pwd home = options[:home] || pwd @@ -41,14 +41,14 @@ def cabal_sandbox(options = {}) end def cabal_sandbox_add_source(*args) - # odeprecated "Language::Haskell::Cabal.cabal_sandbox_add_source" + odeprecated "Language::Haskell::Cabal.cabal_sandbox_add_source" system "cabal", "v1-sandbox", "add-source", *args end def cabal_install(*args) - # odeprecated "Language::Haskell::Cabal.cabal_install", - # "cabal v2-install directly with std_cabal_v2_args" + odeprecated "Language::Haskell::Cabal.cabal_install", + "cabal v2-install directly with std_cabal_v2_args" # cabal hardcodes 64 as the maximum number of parallel jobs # https://github.com/Homebrew/legacy-homebrew/issues/49509 @@ -64,13 +64,13 @@ def cabal_install(*args) end def cabal_configure(flags) - # odeprecated "Language::Haskell::Cabal.cabal_configure" + odeprecated "Language::Haskell::Cabal.cabal_configure" system "cabal", "v1-configure", flags end def cabal_install_tools(*tools) - # odeprecated "Language::Haskell::Cabal.cabal_install_tools" + odeprecated "Language::Haskell::Cabal.cabal_install_tools" # install tools sequentially, as some tools can depend on other tools tools.each { |tool| cabal_install tool } @@ -81,8 +81,8 @@ def cabal_install_tools(*tools) end def install_cabal_package(*args, **options) - # odeprecated "Language::Haskell::Cabal.install_cabal_package", - # "cabal v2-update directly followed by v2-install with std_cabal_v2_args" + odeprecated "Language::Haskell::Cabal.install_cabal_package", + "cabal v2-update directly followed by v2-install with std_cabal_v2_args" cabal_sandbox do cabal_install_tools(*options[:using]) if options[:using] diff --git a/Library/Homebrew/compat/language/python.rb b/Library/Homebrew/compat/language/python.rb index 54784465ba5cd..1012e98dddf5c 100644 --- a/Library/Homebrew/compat/language/python.rb +++ b/Library/Homebrew/compat/language/python.rb @@ -5,6 +5,8 @@ module Python class << self module Compat def rewrite_python_shebang(python_path) + odeprecated "Language::Python.rewrite_python_shebang", + "Utils::Shebang.rewrite_shebang and Shebang.python_shebang_rewrite_info(python_path)" Pathname.pwd.find do |f| Utils::Shebang.rewrite_shebang(Shebang.python_shebang_rewrite_info(python_path), f) end diff --git a/Library/Homebrew/compat/os/mac.rb b/Library/Homebrew/compat/os/mac.rb index af3863c86abcf..b9b6a0bf740f9 100644 --- a/Library/Homebrew/compat/os/mac.rb +++ b/Library/Homebrew/compat/os/mac.rb @@ -5,7 +5,7 @@ module Mac class << self module Compat def preferred_arch - # odeprecated "MacOS.preferred_arch", "Hardware::CPU.arch (or ideally let the compiler handle it)" + odeprecated "MacOS.preferred_arch", "Hardware::CPU.arch (or ideally let the compiler handle it)" if Hardware::CPU.is_64_bit? Hardware::CPU.arch_64_bit else @@ -14,12 +14,12 @@ def preferred_arch end def tcc_db - # odeprecated "MacOS.tcc_db" + odeprecated "MacOS.tcc_db" @tcc_db ||= Pathname.new("/Library/Application Support/com.apple.TCC/TCC.db") end def pre_mavericks_accessibility_dotfile - # odeprecated "MacOS.pre_mavericks_accessibility_dotfile" + odeprecated "MacOS.pre_mavericks_accessibility_dotfile" @pre_mavericks_accessibility_dotfile ||= Pathname.new("/private/var/db/.AccessibilityAPIEnabled") end end diff --git a/Library/Homebrew/compat/requirements/macos_requirement.rb b/Library/Homebrew/compat/requirements/macos_requirement.rb deleted file mode 100644 index 3fe3208d94da6..0000000000000 --- a/Library/Homebrew/compat/requirements/macos_requirement.rb +++ /dev/null @@ -1,35 +0,0 @@ -# frozen_string_literal: true - -class MacOSRequirement < Requirement - module Compat - def initialize(tags = [], comparator: ">=") - if tags.first.respond_to?(:map) - versions, *rest = tags - - versions = versions.map do |v| - next v if v.is_a?(Symbol) - - sym = MacOS::Version.new(v).to_sym - - odisabled "depends_on macos: #{v.inspect}", - "depends_on macos: #{sym.inspect}" - sym - end - - tags = [versions, *rest] - elsif !tags.empty? && !tags.first.is_a?(Symbol) - v, *rest = tags - sym = MacOS::Version.new(v).to_sym - - odisabled "depends_on macos: #{v.inspect}", - "depends_on macos: #{sym.inspect}" - - tags = [sym, *rest] - end - - super(tags, comparator: comparator) - end - end - - prepend Compat -end diff --git a/Library/Homebrew/dev-cmd/audit.rb b/Library/Homebrew/dev-cmd/audit.rb index 87faf0b725c24..94431b87ba65c 100644 --- a/Library/Homebrew/dev-cmd/audit.rb +++ b/Library/Homebrew/dev-cmd/audit.rb @@ -134,19 +134,8 @@ def audit end end - created_pr_comment = false - if new_formula && !new_formula_problem_lines.empty? - begin - created_pr_comment = true if GitHub.create_issue_comment(new_formula_problem_lines.join("\n")) - rescue *GitHub.api_errors => e - opoo "Unable to create issue comment: #{e.message}" - end - end - - unless created_pr_comment - new_formula_problem_count += new_formula_problem_lines.size - puts new_formula_problem_lines.map { |s| " #{s}" } - end + new_formula_problem_count += new_formula_problem_lines.size + puts new_formula_problem_lines.map { |s| " #{s}" } total_problems_count = problem_count + new_formula_problem_count problem_plural = "#{total_problems_count} #{"problem".pluralize(total_problems_count)}" diff --git a/Library/Homebrew/dev-cmd/irb.rb b/Library/Homebrew/dev-cmd/irb.rb index e319acd972c2a..56c164ec5f241 100644 --- a/Library/Homebrew/dev-cmd/irb.rb +++ b/Library/Homebrew/dev-cmd/irb.rb @@ -38,7 +38,7 @@ def irb if args.examples? puts "'v8'.f # => instance of the v8 formula" - puts ":hub.f.installed?" + puts ":hub.f.latest_version_installed?" puts ":lua.f.methods - 1.methods" puts ":mpd.f.recursive_dependencies.reject(&:installed?)" return diff --git a/Library/Homebrew/dev-cmd/pr-pull.rb b/Library/Homebrew/dev-cmd/pr-pull.rb index 039f52cc2a54f..48495a2b5d093 100644 --- a/Library/Homebrew/dev-cmd/pr-pull.rb +++ b/Library/Homebrew/dev-cmd/pr-pull.rb @@ -60,7 +60,7 @@ def setup_git_environment! rescue FormulaUnavailableError nil else - if gnupg.installed? + if gnupg.any_version_installed? path = PATH.new(ENV.fetch("PATH")) path.prepend(gnupg.installed_prefix/"bin") ENV["PATH"] = path diff --git a/Library/Homebrew/dev-cmd/pull.rb b/Library/Homebrew/dev-cmd/pull.rb index 4f1f988569d0b..5950f72bea98e 100644 --- a/Library/Homebrew/dev-cmd/pull.rb +++ b/Library/Homebrew/dev-cmd/pull.rb @@ -56,7 +56,7 @@ def pull gnupg = Formula["gnupg"] rescue FormulaUnavailableError # rubocop:disable Lint/SuppressedException else - if gnupg.installed? + if gnupg.any_version_installed? path = PATH.new(ENV.fetch("PATH")) path.prepend(gnupg.installed_prefix/"bin") ENV["PATH"] = path diff --git a/Library/Homebrew/extend/pathname.rb b/Library/Homebrew/extend/pathname.rb index 98a8cfc1b191d..2837ff096e1c7 100644 --- a/Library/Homebrew/extend/pathname.rb +++ b/Library/Homebrew/extend/pathname.rb @@ -398,15 +398,6 @@ def ds_store? basename.to_s == ".DS_Store" end - # https://bugs.ruby-lang.org/issues/9915 - if RUBY_VERSION == "2.0.0" - prepend Module.new { - def inspect - super.force_encoding(@path.encoding) - end - } - end - def binary_executable? false end diff --git a/Library/Homebrew/extend/string.rb b/Library/Homebrew/extend/string.rb index a0dcb38776849..821902402175b 100644 --- a/Library/Homebrew/extend/string.rb +++ b/Library/Homebrew/extend/string.rb @@ -2,21 +2,6 @@ require "active_support/core_ext/object/blank" -class String - # String.chomp, but if result is empty: returns nil instead. - # Allows `chuzzle || foo` short-circuits. - # TODO: Deprecate. - def chuzzle - s = chomp - s unless s.empty? - end -end - -class NilClass - # TODO: Deprecate. - def chuzzle; end -end - # Used by the inreplace function (in `utils.rb`). module StringInreplaceExtension attr_accessor :errors diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index ab90329020e28..9b62f60c85f42 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -2090,7 +2090,6 @@ def fetch_patches private def prepare_patches - active_spec.add_legacy_patches(patches) if respond_to?(:patches) patchlist.grep(DATAPatch) { |p| p.path = path } end @@ -2171,7 +2170,10 @@ def method_added(method) raise "You cannot override Formula#brew in class #{name}" when :test define_method(:test_defined?) { true } + when :patches + odeprecated "a Formula#patches definition", "'patch do' block calls" when :options + odeprecated "a Formula#options definition", "'option do' block calls" instance = allocate specs.each do |spec| diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 18ed7cb437d28..7e8cc0ca235b4 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -589,7 +589,7 @@ def install_dependency(dep, inherited_options) linked_keg.unlink end - if df.installed? + if df.latest_version_installed? installed_keg = Keg.new(df.prefix) tmp_keg = Pathname.new("#{installed_keg}.tmp") installed_keg.rename(tmp_keg) diff --git a/Library/Homebrew/formulary.rb b/Library/Homebrew/formulary.rb index b01973fab6f54..8448a1298d895 100644 --- a/Library/Homebrew/formulary.rb +++ b/Library/Homebrew/formulary.rb @@ -205,21 +205,16 @@ def initialize(url) def load_file if url =~ %r{githubusercontent.com/[\w-]+/[\w-]+/[a-f0-9]{40}(/Formula)?/([\w+-.@]+).rb} formula_name = Regexp.last_match(2) - opoo <<~EOS - Unsupported installation from a commit URL! - Consider using `brew extract #{formula_name} ...` instead!" - This will extract your desired #{formula_name} version to a stable tap instead of - installing from a commit URL that cannnot receive updates or fixes! - - EOS + odeprecated "Installation of #{formula_name} from a commit URL", + "Use 'brew extract #{formula_name}' to stable tap." end HOMEBREW_CACHE_FORMULA.mkpath FileUtils.rm_f(path) curl_download url, to: path super rescue MethodDeprecatedError => e - if url =~ %r{github.com/([\w-]+)/homebrew-([\w-]+)/} - e.issues_url = "https://github.com/#{Regexp.last_match(1)}/homebrew-#{Regexp.last_match(2)}/issues/new" + if url =~ %r{github.com/([\w-]+)/([\w-]+)/} + e.issues_url = "https://github.com/#{Regexp.last_match(1)}/#{Regexp.last_match(2)}/issues/new" end raise end @@ -483,20 +478,4 @@ def self.tap_paths(name, taps = Dir[HOMEBREW_LIBRARY/"Taps/*/*/"]) ]).find(&:file?) end.compact end - - def self.find_with_priority(ref, spec = :stable) - possible_pinned_tap_formulae = tap_paths(ref, Dir["#{HOMEBREW_LIBRARY}/PinnedTaps/*/*/"]).map(&:realpath) - raise TapFormulaAmbiguityError.new(ref, possible_pinned_tap_formulae) if possible_pinned_tap_formulae.size > 1 - - if possible_pinned_tap_formulae.size == 1 - selected_formula = factory(possible_pinned_tap_formulae.first, spec) - if core_path(ref).file? - odisabled "the brew tap-pin command", - "fully-scoped user/tap/formula naming when installing and in dependency references" - end - selected_formula - else - factory(ref, spec) - end - end end diff --git a/Library/Homebrew/language/python.rb b/Library/Homebrew/language/python.rb index caaa6cb6a4e7e..581ee82ac0289 100644 --- a/Library/Homebrew/language/python.rb +++ b/Library/Homebrew/language/python.rb @@ -33,7 +33,7 @@ def self.each_python(build, &block) next if build.without? python_formula.to_s version = major_minor_version python - ENV["PYTHONPATH"] = if python_formula.installed? + ENV["PYTHONPATH"] = if python_formula.latest_version_installed? nil else homebrew_site_packages(python) diff --git a/Library/Homebrew/patch.rb b/Library/Homebrew/patch.rb index 1050e5bdf4947..03aea114e43ae 100644 --- a/Library/Homebrew/patch.rb +++ b/Library/Homebrew/patch.rb @@ -169,6 +169,7 @@ def inspect # Legacy patches have no checksum and are not cached. class LegacyPatch < ExternalPatch def initialize(strip, url) + odeprecated "legacy patches", "'patch do' blocks" super(strip) resource.url(url) resource.download_strategy = CurlDownloadStrategy diff --git a/Library/Homebrew/requirements/java_requirement.rb b/Library/Homebrew/requirements/java_requirement.rb index 1c324df27311c..6d7c66c73ceae 100644 --- a/Library/Homebrew/requirements/java_requirement.rb +++ b/Library/Homebrew/requirements/java_requirement.rb @@ -111,7 +111,7 @@ def possible_javas rescue FormulaUnavailableError nil end - javas << jdk.bin/"java" if jdk&.installed? + javas << jdk.bin/"java" if jdk&.latest_version_installed? javas << which("java") javas end diff --git a/Library/Homebrew/software_spec.rb b/Library/Homebrew/software_spec.rb index 0e31f23b9f8ff..72da2a2da1978 100644 --- a/Library/Homebrew/software_spec.rb +++ b/Library/Homebrew/software_spec.rb @@ -221,6 +221,7 @@ def needs(*standards) end end + # TODO def add_legacy_patches(list) list = Patch.normalize_legacy_patches(list) list.each { |p| p.owner = self } diff --git a/Library/Homebrew/test/formula_spec.rb b/Library/Homebrew/test/formula_spec.rb index 6daf45f1ab800..f7c13c6cebb2b 100644 --- a/Library/Homebrew/test/formula_spec.rb +++ b/Library/Homebrew/test/formula_spec.rb @@ -644,25 +644,6 @@ expect(f.head.version).to eq(Version.create("HEAD-5658946")) end - specify "legacy options" do - f = formula do - url "foo-1.0" - - def options - [ - ["--foo", "desc"], - ["--bar", "desc"], - ] - end - - option("baz") - end - - expect(f).to have_option_defined("foo") - expect(f).to have_option_defined("bar") - expect(f).to have_option_defined("baz") - end - specify "#desc" do f = formula do desc "a formula" @@ -673,23 +654,6 @@ def options expect(f.desc).to eq("a formula") end - specify "#test_defined?" do - f1 = formula do - url "foo-1.0" - - def test - # do nothing - end - end - - f2 = formula do - url "foo-1.0" - end - - expect(f1).to have_test_defined - expect(f2).not_to have_test_defined - end - specify "test fixtures" do f1 = formula do url "foo-1.0" diff --git a/Library/Homebrew/test/formulary_spec.rb b/Library/Homebrew/test/formulary_spec.rb index 157b608050206..5458fc6e024b6 100644 --- a/Library/Homebrew/test/formulary_spec.rb +++ b/Library/Homebrew/test/formulary_spec.rb @@ -234,22 +234,6 @@ class Wrong#{described_class.class_s(formula_name)} < Formula end end - describe "::find_with_priority" do - let(:core_path) { CoreTap.new.formula_dir/"#{formula_name}.rb" } - let(:tap) { Tap.new("homebrew", "foo") } - let(:tap_path) { tap.path/"#{formula_name}.rb" } - - before do - core_path.write formula_content - tap_path.write formula_content - end - - it "prioritizes core Formulae" do - formula = described_class.find_with_priority(formula_name) - expect(formula.path).to eq(core_path) - end - end - describe "::core_path" do it "returns the path to a Formula in the core tap" do name = "foo-bar" diff --git a/Library/Homebrew/test/patch_spec.rb b/Library/Homebrew/test/patch_spec.rb index 463894ff4c651..fff1fc48b287f 100644 --- a/Library/Homebrew/test/patch_spec.rb +++ b/Library/Homebrew/test/patch_spec.rb @@ -74,74 +74,6 @@ expect(subject.patch_files.count).to eq(7) end end - - describe "#normalize_legacy_patches" do - it "can create a patch from a single string" do - patches = described_class.normalize_legacy_patches("https://brew.sh/patch.diff") - expect(patches.length).to eq(1) - expect(patches.first.strip).to eq(:p1) - end - - it "can create patches from an array" do - patches = described_class.normalize_legacy_patches( - %w[https://brew.sh/patch1.diff https://brew.sh/patch2.diff], - ) - - expect(patches.length).to eq(2) - expect(patches.first.strip).to eq(:p1) - expect(patches.second.strip).to eq(:p1) - end - - it "can create patches from a :p0 hash" do - patches = described_class.normalize_legacy_patches( - p0: "https://brew.sh/patch.diff", - ) - - expect(patches.length).to eq(1) - expect(patches.first.strip).to eq(:p0) - end - - it "can create patches from a :p1 hash" do - patches = described_class.normalize_legacy_patches( - p1: "https://brew.sh/patch.diff", - ) - - expect(patches.length).to eq(1) - expect(patches.first.strip).to eq(:p1) - end - - it "can create patches from a mixed hash" do - patches = described_class.normalize_legacy_patches( - p1: "https://brew.sh/patch1.diff", - p0: "https://brew.sh/patch0.diff", - ) - - expect(patches.length).to eq(2) - expect(patches.count { |p| p.strip == :p0 }).to eq(1) - expect(patches.count { |p| p.strip == :p1 }).to eq(1) - end - - it "can create patches from a mixed hash with array" do - patches = described_class.normalize_legacy_patches( - p1: [ - "https://brew.sh/patch10.diff", - "https://brew.sh/patch11.diff", - ], - p0: [ - "https://brew.sh/patch00.diff", - "https://brew.sh/patch01.diff", - ], - ) - - expect(patches.length).to eq(4) - expect(patches.count { |p| p.strip == :p0 }).to eq(2) - expect(patches.count { |p| p.strip == :p1 }).to eq(2) - end - - it "returns an empty array if given nil" do - expect(described_class.normalize_legacy_patches(nil)).to be_empty - end - end end describe EmbeddedPatch do diff --git a/Library/Homebrew/test/patching_spec.rb b/Library/Homebrew/test/patching_spec.rb index b921bb5d76c53..ffdf1027dc5ae 100644 --- a/Library/Homebrew/test/patching_spec.rb +++ b/Library/Homebrew/test/patching_spec.rb @@ -65,16 +65,6 @@ def formula(name = "formula_name", path: Formulary.core_path(name), spec: :stabl end end - specify "single_patch" do - expect( - formula do - def patches - PATCH_URL_A - end - end, - ).to be_patched - end - specify "single_patch_dsl" do expect( formula do @@ -199,46 +189,6 @@ def patches ).to be_patched end - specify "patch_p0" do - expect( - formula do - def patches - { p0: PATCH_URL_B } - end - end, - ).to be_patched - end - - specify "patch_array" do - expect( - formula do - def patches - [PATCH_URL_A] - end - end, - ).to be_patched - end - - specify "patch_hash" do - expect( - formula do - def patches - { p1: PATCH_URL_A } - end - end, - ).to be_patched - end - - specify "patch_hash_array" do - expect( - formula do - def patches - { p1: [PATCH_URL_A] } - end - end, - ).to be_patched - end - specify "patch_string" do expect(formula { patch PATCH_A_CONTENTS }).to be_patched end @@ -247,26 +197,6 @@ def patches expect(formula { patch :p0, PATCH_B_CONTENTS }).to be_patched end - specify "patch_data_constant" do - expect( - formula("test", path: Pathname.new(__FILE__).expand_path) do - def patches - :DATA - end - end, - ).to be_patched - end - - specify "single_patch_missing_apply_fail" do - expect( - formula do - def patches - TESTBALL_PATCHES_URL - end - end, - ).to miss_apply - end - specify "single_patch_dsl_missing_apply_fail" do expect( formula do diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index 1768ed6b567f0..3b82876072a86 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -14,8 +14,6 @@ module GitHub ALL_SCOPES_URL = Formatter.url( "https://github.com/settings/tokens/new?scopes=#{ALL_SCOPES.join(",")}&description=Homebrew", ).freeze - PR_ENV_KEY = "HOMEBREW_NEW_FORMULA_PULL_REQUEST_URL" - PR_ENV = ENV[PR_ENV_KEY] class Error < RuntimeError attr_reader :github_message @@ -396,37 +394,6 @@ def search(entity, *queries, **qualifiers) open_api(uri) { |json| json.fetch("items", []) } end - def create_issue_comment(body) - return false unless PR_ENV - - _, user, repo, pr = *PR_ENV.match(HOMEBREW_PULL_OR_COMMIT_URL_REGEX) - if !user || !repo || !pr - opoo <<-EOS.undent - #{PR_ENV_KEY} set but regex matched: - user: #{user.inspect}, repo: #{repo.inspect}, pr: #{pr.inspect} - EOS - return false - end - - url = "#{API_URL}/repos/#{user}/#{repo}/issues/#{pr}/comments" - data = { "body" => body } - if issue_comment_exists?(user, repo, pr, body) - ohai "Skipping: identical comment exists on #{PR_ENV}" - return true - end - - scopes = CREATE_ISSUE_FORK_OR_PR_SCOPES - open_api(url, data: data, scopes: scopes) - end - - def issue_comment_exists?(user, repo, pr, body) - url = "#{API_URL}/repos/#{user}/#{repo}/issues/#{pr}/comments" - comments = open_api(url) - return unless comments - - comments.any? { |comment| comment["body"].eql?(body) } - end - def dispatch_event(user, repo, event, **payload) url = "#{API_URL}/repos/#{user}/#{repo}/dispatches" open_api(url, data: { event_type: event, client_payload: payload },