mirror of
https://github.com/donl/homebrew-cask-versions.git
synced 2026-07-17 06:16:47 -06:00
Merge pull request #8197 from rolandwalker/remove_homebrew_debrew
remove `debrew.rb` from homebrew-fork
This commit is contained in:
commit
139a723179
2 changed files with 0 additions and 164 deletions
|
|
@ -8,7 +8,6 @@ require "build_options"
|
|||
require "cxxstdlib"
|
||||
require "keg"
|
||||
require "extend/ENV"
|
||||
require "debrew"
|
||||
require "fcntl"
|
||||
|
||||
class Build
|
||||
|
|
@ -38,11 +37,6 @@ class Build
|
|||
ENV.setup_build_environment(formula)
|
||||
end
|
||||
|
||||
if ARGV.debug?
|
||||
formula.extend(Debrew::Formula)
|
||||
formula.resources.each { |r| r.extend(Debrew::Resource) }
|
||||
end
|
||||
|
||||
formula.brew do
|
||||
if ARGV.flag? '--git'
|
||||
system "git", "init"
|
||||
|
|
|
|||
|
|
@ -1,158 +0,0 @@
|
|||
require "mutex_m"
|
||||
|
||||
module Debrew
|
||||
extend Mutex_m
|
||||
|
||||
Ignorable = Module.new
|
||||
|
||||
module Raise
|
||||
def raise(*)
|
||||
super
|
||||
rescue Exception => e
|
||||
e.extend(Ignorable)
|
||||
super(e) unless Debrew.debug(e) == :ignore
|
||||
end
|
||||
|
||||
alias_method :fail, :raise
|
||||
end
|
||||
|
||||
module Formula
|
||||
def install
|
||||
Debrew.debrew { super }
|
||||
end
|
||||
|
||||
def test
|
||||
Debrew.debrew { super }
|
||||
end
|
||||
end
|
||||
|
||||
module Resource
|
||||
def unpack(target=nil)
|
||||
return super if target
|
||||
super do
|
||||
begin
|
||||
yield self
|
||||
rescue Exception => e
|
||||
Debrew.debug(e)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class Menu
|
||||
Entry = Struct.new(:name, :action)
|
||||
|
||||
attr_accessor :prompt, :entries
|
||||
|
||||
def initialize
|
||||
@entries = []
|
||||
end
|
||||
|
||||
def choice(name, &action)
|
||||
entries << Entry.new(name.to_s, action)
|
||||
end
|
||||
|
||||
def self.choose
|
||||
menu = new
|
||||
yield menu
|
||||
|
||||
choice = nil
|
||||
while choice.nil?
|
||||
menu.entries.each_with_index { |e, i| puts "#{i+1}. #{e.name}" }
|
||||
print menu.prompt unless menu.prompt.nil?
|
||||
|
||||
input = $stdin.gets or exit
|
||||
input.chomp!
|
||||
|
||||
i = input.to_i
|
||||
if i > 0
|
||||
choice = menu.entries[i-1]
|
||||
else
|
||||
possible = menu.entries.find_all { |e| e.name.start_with?(input) }
|
||||
|
||||
case possible.size
|
||||
when 0 then puts "No such option"
|
||||
when 1 then choice = possible.first
|
||||
else puts "Multiple options match: #{possible.map(&:name).join(" ")}"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
choice[:action].call
|
||||
end
|
||||
end
|
||||
|
||||
class << self
|
||||
alias_method :original_raise, :raise
|
||||
end
|
||||
|
||||
@active = false
|
||||
@debugged_exceptions = Set.new
|
||||
|
||||
def self.active?
|
||||
@active
|
||||
end
|
||||
|
||||
def self.debugged_exceptions
|
||||
@debugged_exceptions
|
||||
end
|
||||
|
||||
def self.debrew
|
||||
@active = true
|
||||
Object.send(:include, Raise)
|
||||
|
||||
begin
|
||||
yield
|
||||
rescue SystemExit
|
||||
original_raise
|
||||
rescue Exception => e
|
||||
debug(e)
|
||||
ensure
|
||||
@active = false
|
||||
end
|
||||
end
|
||||
|
||||
def self.debug(e)
|
||||
original_raise(e) unless active? &&
|
||||
debugged_exceptions.add?(e) &&
|
||||
try_lock
|
||||
|
||||
begin
|
||||
puts "#{e.backtrace.first}"
|
||||
puts "#{Tty.red}#{e.class.name}#{Tty.reset}: #{e}"
|
||||
|
||||
loop do
|
||||
Menu.choose do |menu|
|
||||
menu.prompt = "Choose an action: "
|
||||
|
||||
menu.choice(:raise) { original_raise(e) }
|
||||
menu.choice(:ignore) { return :ignore } if Ignorable === e
|
||||
menu.choice(:backtrace) { puts e.backtrace }
|
||||
|
||||
unless ENV["HOMEBREW_NO_READLINE"]
|
||||
require "debrew/irb"
|
||||
|
||||
menu.choice(:irb) do
|
||||
puts "When you exit this IRB session, execution will continue."
|
||||
set_trace_func proc { |event, _, _, id, binding, klass|
|
||||
if klass == Raise && id == :raise && event == "return"
|
||||
set_trace_func(nil)
|
||||
synchronize { IRB.start_within(binding) }
|
||||
end
|
||||
}
|
||||
|
||||
return :ignore
|
||||
end if Ignorable === e
|
||||
end
|
||||
|
||||
menu.choice(:shell) do
|
||||
puts "When you exit this shell, you will return to the menu."
|
||||
interactive_shell
|
||||
end
|
||||
end
|
||||
end
|
||||
ensure
|
||||
unlock
|
||||
end
|
||||
end
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue