From fe4dc6f2415a2dc731f9af448fb85f28cb4a1f63 Mon Sep 17 00:00:00 2001 From: Anastasia Sulyagina Date: Tue, 5 Jul 2016 09:59:26 +0400 Subject: [PATCH] Delete exceptions from homebrew-fork (#22574) * delete exceptions from homebrew-fork * paths fix --- Rakefile | 2 ++ lib/hbc/source/uri.rb | 2 +- lib/vendor/homebrew-fork/download_strategy.rb | 6 +++--- lib/vendor/homebrew-fork/exceptions.rb | 12 ------------ lib/vendor/homebrew-fork/global.rb | 2 +- lib/vendor/homebrew-fork/utils.rb | 4 ++-- spec/spec_helper.rb | 3 +++ test/test_helper.rb | 3 +++ 8 files changed, 15 insertions(+), 19 deletions(-) delete mode 100644 lib/vendor/homebrew-fork/exceptions.rb diff --git a/Rakefile b/Rakefile index 05fd6e7046..ed935451e2 100644 --- a/Rakefile +++ b/Rakefile @@ -3,6 +3,8 @@ require 'rake/testtask' require 'rspec/core/rake_task' require 'rubocop/rake_task' +homebrew_repo = `brew --repository` +$LOAD_PATH.unshift(File.expand_path("#{homebrew_repo.chomp}/Library/Homebrew")) $LOAD_PATH.unshift(File.expand_path('../lib', __FILE__)) namespace :test do diff --git a/lib/hbc/source/uri.rb b/lib/hbc/source/uri.rb index 4435e61310..2d8fe5b60b 100644 --- a/lib/hbc/source/uri.rb +++ b/lib/hbc/source/uri.rb @@ -16,7 +16,7 @@ class Hbc::Source::URI odebug "Download target -> #{path.to_s}" begin curl(uri, '-o', path.to_s) - rescue Hbc::ErrorDuringExecution + rescue ErrorDuringExecution raise Hbc::CaskUnavailableError.new uri end Hbc::Source::PathSlashOptional.new(path).load diff --git a/lib/vendor/homebrew-fork/download_strategy.rb b/lib/vendor/homebrew-fork/download_strategy.rb index 2aec0ca936..e0679d54a0 100644 --- a/lib/vendor/homebrew-fork/download_strategy.rb +++ b/lib/vendor/homebrew-fork/download_strategy.rb @@ -63,7 +63,7 @@ class Hbc::HbCurlDownloadStrategy < Hbc::AbstractDownloadStrategy had_incomplete_download = temporary_path.exist? begin _fetch - rescue Hbc::ErrorDuringExecution + rescue ErrorDuringExecution # 33 == range not supported # try wiping the incomplete download and retrying once if $?.exitstatus == 33 && had_incomplete_download @@ -78,14 +78,14 @@ class Hbc::HbCurlDownloadStrategy < Hbc::AbstractDownloadStrategy msg = "Download failed: #{@url}" msg << "\nThe incomplete download is cached at #{tarball_path}" end - raise Hbc::CurlDownloadStrategyError, msg + raise CurlDownloadStrategyError, msg end end Hbc::Utils.ignore_interrupts { temporary_path.rename(tarball_path) } else puts "Already downloaded: #{tarball_path}" end - rescue Hbc::CurlDownloadStrategyError + rescue CurlDownloadStrategyError raise if mirrors.empty? puts "Trying a mirror..." @url = mirrors.shift diff --git a/lib/vendor/homebrew-fork/exceptions.rb b/lib/vendor/homebrew-fork/exceptions.rb deleted file mode 100644 index 7f2da906ba..0000000000 --- a/lib/vendor/homebrew-fork/exceptions.rb +++ /dev/null @@ -1,12 +0,0 @@ -module Hbc; end - -# raised by safe_system in utils.rb -class Hbc::ErrorDuringExecution < RuntimeError - def initialize(cmd, args=[]) - args = args.map { |a| a.to_s.gsub " ", "\\ " }.join(" ") - super "Failure while executing: #{cmd} #{args}" - end -end - -# raised in Hbc::HbCurlDownloadStrategy.fetch -class Hbc::CurlDownloadStrategyError < RuntimeError; end diff --git a/lib/vendor/homebrew-fork/global.rb b/lib/vendor/homebrew-fork/global.rb index 738d2d6a33..bfd69c1ee4 100644 --- a/lib/vendor/homebrew-fork/global.rb +++ b/lib/vendor/homebrew-fork/global.rb @@ -1,5 +1,5 @@ +require 'exceptions' require 'vendor/homebrew-fork/monkeypatch_pathname' -require 'vendor/homebrew-fork/exceptions' require 'vendor/homebrew-fork/utils' def cache diff --git a/lib/vendor/homebrew-fork/utils.rb b/lib/vendor/homebrew-fork/utils.rb index 5fa838affb..c15483e7f1 100644 --- a/lib/vendor/homebrew-fork/utils.rb +++ b/lib/vendor/homebrew-fork/utils.rb @@ -1,5 +1,5 @@ require 'pathname' -require 'vendor/homebrew-fork/exceptions' +require 'exceptions' def homebrew_fork_system cmd, *args puts "#{cmd} #{args*' '}" if Hbc.verbose @@ -15,7 +15,7 @@ end # Kernel.system but with exceptions def safe_system cmd, *args - homebrew_fork_system(cmd, *args) or raise Hbc::ErrorDuringExecution.new(cmd, args) + homebrew_fork_system(cmd, *args) or raise ErrorDuringExecution.new(cmd, args) end # prints no output diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 6e8893782e..2b7bc7b6ac 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -2,6 +2,9 @@ require 'pathname' require 'rspec/its' require 'rspec/wait' +homebrew_repo = `brew --repository` +$LOAD_PATH.unshift(File.expand_path("#{homebrew_repo.chomp}/Library/Homebrew")) + if ENV['COVERAGE'] require 'coveralls' Coveralls.wear_merged! diff --git a/test/test_helper.rb b/test/test_helper.rb index 44d2e49571..01ca50a35f 100644 --- a/test/test_helper.rb +++ b/test/test_helper.rb @@ -2,6 +2,9 @@ require 'bundler' require 'bundler/setup' require 'pathname' +homebrew_repo = `brew --repository` +$LOAD_PATH.unshift(File.expand_path("#{homebrew_repo.chomp}/Library/Homebrew")) + if ENV['COVERAGE'] require 'coveralls' Coveralls.wear_merged!