Switch back to monkey-patching

Also gsub! some particular formula contents to work around older
formulae ("brewkit" isn't around anymore, and url is expected to
be a method, not an instance variable).
This commit is contained in:
Caleb Xu 2018-08-16 12:52:54 -04:00
parent 95abdf9662
commit 260867627b

View File

@ -15,45 +15,46 @@ require "utils/git"
require "formulary" require "formulary"
require "tap" require "tap"
module ExtractExtensions class BottleSpecification
refine BottleSpecification do def method_missing(m, *_args, &_block)
def method_missing(m, *_args, &_block) # no-op
end
end
class Module
def method_missing(m, *_args, &_block)
# no-op
end
end
class DependencyCollector
def parse_symbol_spec(spec, tags)
case spec
when :x11 then X11Requirement.new(spec.to_s, tags)
when :xcode then XcodeRequirement.new(tags)
when :linux then LinuxRequirement.new(tags)
when :macos then MacOSRequirement.new(tags)
when :arch then ArchRequirement.new(tags)
when :java then JavaRequirement.new(tags)
when :osxfuse then OsxfuseRequirement.new(tags)
when :tuntap then TuntapRequirement.new(tags)
when :ld64 then ld64_dep_if_needed(tags)
else
# no-op # no-op
end end
end end
refine Module do module Compat
def method_missing(m, *_args, &_block)
# no-op
end
end
refine DependencyCollector do
def parse_symbol_spec(spec, tags)
case spec
when :x11 then X11Requirement.new(spec.to_s, tags)
when :xcode then XcodeRequirement.new(tags)
when :linux then LinuxRequirement.new(tags)
when :macos then MacOSRequirement.new(tags)
when :arch then ArchRequirement.new(tags)
when :java then JavaRequirement.new(tags)
when :osxfuse then OsxfuseRequirement.new(tags)
when :tuntap then TuntapRequirement.new(tags)
when :ld64 then ld64_dep_if_needed(tags)
else
# no-op
end
end
def parse_string_spec(spec, tags) def parse_string_spec(spec, tags)
opoo "'depends_on ... => :run' is disabled. There is no replacement." if tags.include?(:run) && ARGV.debug? opoo "'depends_on ... => :run' is disabled. There is no replacement." if tags.include?(:run) && ARGV.debug?
super super
end end
end end
prepend Compat
end end
module Homebrew module Homebrew
using ExtractExtensions
module_function module_function
def extract def extract
@ -124,6 +125,8 @@ module Homebrew
def formula_at_revision(repo, name, file, rev) def formula_at_revision(repo, name, file, rev)
return if rev.empty? return if rev.empty?
contents = Git.last_revision_of_file(repo, file, before_commit: rev) contents = Git.last_revision_of_file(repo, file, before_commit: rev)
contents.gsub!("@url=", "url ")
contents.gsub!("require 'brewkit'", "require 'formula'")
Formulary.from_contents(name, file, contents) Formulary.from_contents(name, file, contents)
end end
end end