Merge pull request #7579 from MikeMcQuaid/deprecations
Update deprecations
This commit is contained in:
commit
e1f3c8d2b3
@ -84,7 +84,7 @@ module CleanupRefinement
|
||||
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)
|
||||
|
||||
|
||||
@ -84,11 +84,7 @@ module Homebrew
|
||||
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
|
||||
end.uniq(&:name).freeze
|
||||
end
|
||||
|
||||
|
||||
@ -359,11 +359,7 @@ module Homebrew
|
||||
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
|
||||
end.compact.uniq(&:name)
|
||||
end
|
||||
end
|
||||
|
||||
@ -36,7 +36,6 @@ module Homebrew
|
||||
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
|
||||
|
||||
@ -105,11 +105,7 @@ module Homebrew
|
||||
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
|
||||
if args.analytics?
|
||||
Utils::Analytics.formula_output(formula)
|
||||
else
|
||||
|
||||
@ -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
|
||||
@ -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
|
||||
@ -216,7 +216,7 @@ module Homebrew
|
||||
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
|
||||
|
||||
@ -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?
|
||||
|
||||
@ -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
|
||||
11
Library/Homebrew/compat/extend/nil.rb
Normal file
11
Library/Homebrew/compat/extend/nil.rb
Normal file
@ -0,0 +1,11 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class NilClass
|
||||
module Compat
|
||||
def chuzzle
|
||||
odeprecated "chuzzle", "chomp.presence"
|
||||
end
|
||||
end
|
||||
|
||||
prepend Compat
|
||||
end
|
||||
15
Library/Homebrew/compat/extend/string.rb
Normal file
15
Library/Homebrew/compat/extend/string.rb
Normal file
@ -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
|
||||
@ -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
|
||||
|
||||
@ -5,7 +5,7 @@ module Language
|
||||
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 @@ module Language
|
||||
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 @@ module Language
|
||||
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 @@ module Language
|
||||
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]
|
||||
|
||||
@ -5,6 +5,8 @@ module Language
|
||||
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
|
||||
|
||||
@ -5,7 +5,7 @@ module OS
|
||||
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 @@ module OS
|
||||
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
|
||||
|
||||
@ -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
|
||||
@ -134,19 +134,8 @@ module Homebrew
|
||||
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
|
||||
|
||||
total_problems_count = problem_count + new_formula_problem_count
|
||||
problem_plural = "#{total_problems_count} #{"problem".pluralize(total_problems_count)}"
|
||||
|
||||
@ -38,7 +38,7 @@ module Homebrew
|
||||
|
||||
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
|
||||
|
||||
@ -60,7 +60,7 @@ module Homebrew
|
||||
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
|
||||
|
||||
@ -56,7 +56,7 @@ module Homebrew
|
||||
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
|
||||
|
||||
@ -398,15 +398,6 @@ class Pathname
|
||||
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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -2090,7 +2090,6 @@ class Formula
|
||||
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 @@ class Formula
|
||||
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|
|
||||
|
||||
@ -594,7 +594,7 @@ class FormulaInstaller
|
||||
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)
|
||||
|
||||
@ -205,21 +205,16 @@ module Formulary
|
||||
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 @@ module Formulary
|
||||
]).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
|
||||
|
||||
@ -33,7 +33,7 @@ module Language
|
||||
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)
|
||||
|
||||
@ -169,6 +169,7 @@ end
|
||||
# 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
|
||||
|
||||
@ -111,7 +111,7 @@ class JavaRequirement < Requirement
|
||||
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
|
||||
|
||||
@ -221,6 +221,7 @@ class SoftwareSpec
|
||||
end
|
||||
end
|
||||
|
||||
# TODO
|
||||
def add_legacy_patches(list)
|
||||
list = Patch.normalize_legacy_patches(list)
|
||||
list.each { |p| p.owner = self }
|
||||
|
||||
@ -644,25 +644,6 @@ describe Formula do
|
||||
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 @@ describe Formula do
|
||||
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"
|
||||
|
||||
@ -234,22 +234,6 @@ describe Formulary do
|
||||
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"
|
||||
|
||||
@ -74,74 +74,6 @@ describe Patch do
|
||||
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
|
||||
|
||||
@ -65,16 +65,6 @@ describe "patching" do
|
||||
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 @@ describe "patching" do
|
||||
).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 @@ describe "patching" do
|
||||
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
|
||||
|
||||
@ -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 @@ module GitHub
|
||||
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 },
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user