mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Auto-fix Style/RedundantBegin offenses
- This also required auto-fixes for Layout/EmptyLinesAroundBlockBody and Layout/InconsistentIndentation once the auto-fixer had got rid of the "redundant begin"s.
This commit is contained in:
parent
b78028b9c2
commit
341ea60807
@ -142,17 +142,15 @@ class BottlePublisher
|
|||||||
retry_count = 0
|
retry_count = 0
|
||||||
# We're in the cache; make sure to force re-download
|
# We're in the cache; make sure to force re-download
|
||||||
loop do
|
loop do
|
||||||
begin
|
curl_download url, to: filename
|
||||||
curl_download url, to: filename
|
break
|
||||||
break
|
rescue
|
||||||
rescue
|
raise "Failed to download #{f} bottle from #{url}!" if retry_count >= max_curl_retries
|
||||||
raise "Failed to download #{f} bottle from #{url}!" if retry_count >= max_curl_retries
|
|
||||||
|
|
||||||
puts "curl download failed; retrying in #{curl_retry_delay_seconds} sec"
|
puts "curl download failed; retrying in #{curl_retry_delay_seconds} sec"
|
||||||
sleep curl_retry_delay_seconds
|
sleep curl_retry_delay_seconds
|
||||||
curl_retry_delay_seconds *= 2
|
curl_retry_delay_seconds *= 2
|
||||||
retry_count += 1
|
retry_count += 1
|
||||||
end
|
|
||||||
end
|
end
|
||||||
checksum = Checksum.new(:sha256, bottle_info["sha256"])
|
checksum = Checksum.new(:sha256, bottle_info["sha256"])
|
||||||
Pathname.new(filename).verify_checksum(checksum)
|
Pathname.new(filename).verify_checksum(checksum)
|
||||||
|
@ -65,13 +65,11 @@ module Cask
|
|||||||
return yield nil if choices.empty?
|
return yield nil if choices.empty?
|
||||||
|
|
||||||
Tempfile.open(["choices", ".xml"]) do |file|
|
Tempfile.open(["choices", ".xml"]) do |file|
|
||||||
begin
|
file.write Plist::Emit.dump(choices)
|
||||||
file.write Plist::Emit.dump(choices)
|
file.close
|
||||||
file.close
|
yield file.path
|
||||||
yield file.path
|
ensure
|
||||||
ensure
|
file.unlink
|
||||||
file.unlink
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -19,11 +19,9 @@ module Cask
|
|||||||
return to_enum unless block_given?
|
return to_enum unless block_given?
|
||||||
|
|
||||||
Tap.flat_map(&:cask_files).each do |f|
|
Tap.flat_map(&:cask_files).each do |f|
|
||||||
begin
|
yield CaskLoader::FromTapPathLoader.new(f).load
|
||||||
yield CaskLoader::FromTapPathLoader.new(f).load
|
rescue CaskUnreadableError => e
|
||||||
rescue CaskUnreadableError => e
|
opoo e.message
|
||||||
opoo e.message
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -200,11 +200,9 @@ module Cask
|
|||||||
end
|
end
|
||||||
|
|
||||||
remaining = all_args.select do |arg|
|
remaining = all_args.select do |arg|
|
||||||
begin
|
!process_arguments([arg]).empty?
|
||||||
!process_arguments([arg]).empty?
|
rescue OptionParser::InvalidOption, OptionParser::MissingArgument, OptionParser::AmbiguousOption
|
||||||
rescue OptionParser::InvalidOption, OptionParser::MissingArgument, OptionParser::AmbiguousOption
|
true
|
||||||
true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
remaining + non_options
|
remaining + non_options
|
||||||
|
@ -14,16 +14,14 @@ module Cask
|
|||||||
def run
|
def run
|
||||||
odie "Installing casks is supported only on macOS" unless OS.mac?
|
odie "Installing casks is supported only on macOS" unless OS.mac?
|
||||||
casks.each do |cask|
|
casks.each do |cask|
|
||||||
begin
|
Installer.new(cask, binaries: binaries?,
|
||||||
Installer.new(cask, binaries: binaries?,
|
verbose: verbose?,
|
||||||
verbose: verbose?,
|
force: force?,
|
||||||
force: force?,
|
skip_cask_deps: skip_cask_deps?,
|
||||||
skip_cask_deps: skip_cask_deps?,
|
require_sha: require_sha?,
|
||||||
require_sha: require_sha?,
|
quarantine: quarantine?).install
|
||||||
quarantine: quarantine?).install
|
rescue CaskAlreadyInstalledError => e
|
||||||
rescue CaskAlreadyInstalledError => e
|
opoo e.message
|
||||||
opoo e.message
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -45,12 +45,10 @@ module Cask
|
|||||||
return if dry_run?
|
return if dry_run?
|
||||||
|
|
||||||
upgradable_casks.each do |(old_cask, new_cask)|
|
upgradable_casks.each do |(old_cask, new_cask)|
|
||||||
begin
|
upgrade_cask(old_cask, new_cask)
|
||||||
upgrade_cask(old_cask, new_cask)
|
rescue CaskError => e
|
||||||
rescue CaskError => e
|
caught_exceptions << e
|
||||||
caught_exceptions << e
|
next
|
||||||
next
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
return if caught_exceptions.empty?
|
return if caught_exceptions.empty?
|
||||||
|
@ -137,11 +137,9 @@ module Cask
|
|||||||
|
|
||||||
locales = MacOS.languages
|
locales = MacOS.languages
|
||||||
.map do |language|
|
.map do |language|
|
||||||
begin
|
Locale.parse(language)
|
||||||
Locale.parse(language)
|
rescue Locale::ParserError
|
||||||
rescue Locale::ParserError
|
nil
|
||||||
nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
.compact
|
.compact
|
||||||
|
|
||||||
@ -255,18 +253,16 @@ module Cask
|
|||||||
|
|
||||||
ORDINARY_ARTIFACT_CLASSES.each do |klass|
|
ORDINARY_ARTIFACT_CLASSES.each do |klass|
|
||||||
define_method(klass.dsl_key) do |*args|
|
define_method(klass.dsl_key) do |*args|
|
||||||
begin
|
if [*artifacts.map(&:class), klass].include?(Artifact::StageOnly) &&
|
||||||
if [*artifacts.map(&:class), klass].include?(Artifact::StageOnly) &&
|
(artifacts.map(&:class) & ACTIVATABLE_ARTIFACT_CLASSES).any?
|
||||||
(artifacts.map(&:class) & ACTIVATABLE_ARTIFACT_CLASSES).any?
|
raise CaskInvalidError.new(cask, "'stage_only' must be the only activatable artifact.")
|
||||||
raise CaskInvalidError.new(cask, "'stage_only' must be the only activatable artifact.")
|
|
||||||
end
|
|
||||||
|
|
||||||
artifacts.add(klass.from_args(cask, *args))
|
|
||||||
rescue CaskInvalidError
|
|
||||||
raise
|
|
||||||
rescue => e
|
|
||||||
raise CaskInvalidError.new(cask, "invalid '#{klass.dsl_key}' stanza: #{e}")
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
artifacts.add(klass.from_args(cask, *args))
|
||||||
|
rescue CaskInvalidError
|
||||||
|
raise
|
||||||
|
rescue => e
|
||||||
|
raise CaskInvalidError.new(cask, "invalid '#{klass.dsl_key}' stanza: #{e}")
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -111,12 +111,10 @@ module Cask
|
|||||||
return unless @cask.conflicts_with
|
return unless @cask.conflicts_with
|
||||||
|
|
||||||
@cask.conflicts_with[:cask].each do |conflicting_cask|
|
@cask.conflicts_with[:cask].each do |conflicting_cask|
|
||||||
begin
|
conflicting_cask = CaskLoader.load(conflicting_cask)
|
||||||
conflicting_cask = CaskLoader.load(conflicting_cask)
|
raise CaskConflictError.new(@cask, conflicting_cask) if conflicting_cask.installed?
|
||||||
raise CaskConflictError.new(@cask, conflicting_cask) if conflicting_cask.installed?
|
rescue CaskUnavailableError
|
||||||
rescue CaskUnavailableError
|
next # Ignore conflicting Casks that do not exist.
|
||||||
next # Ignore conflicting Casks that do not exist.
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -86,11 +86,9 @@ class Caveats
|
|||||||
|
|
||||||
def keg
|
def keg
|
||||||
@keg ||= [f.prefix, f.opt_prefix, f.linked_keg].map do |d|
|
@keg ||= [f.prefix, f.opt_prefix, f.linked_keg].map do |d|
|
||||||
begin
|
Keg.new(d.resolved_path)
|
||||||
Keg.new(d.resolved_path)
|
rescue
|
||||||
rescue
|
nil
|
||||||
nil
|
|
||||||
end
|
|
||||||
end.compact.first
|
end.compact.first
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -25,11 +25,9 @@ module Homebrew
|
|||||||
|
|
||||||
deps_of_installed = installed.flat_map do |f|
|
deps_of_installed = installed.flat_map do |f|
|
||||||
f.runtime_dependencies.map do |dep|
|
f.runtime_dependencies.map do |dep|
|
||||||
begin
|
dep.to_formula.full_name
|
||||||
dep.to_formula.full_name
|
rescue FormulaUnavailableError
|
||||||
rescue FormulaUnavailableError
|
dep.name
|
||||||
dep.name
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -382,21 +382,19 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
reinstallable.each do |f|
|
reinstallable.each do |f|
|
||||||
begin
|
reinstall_formula(f, build_from_source: true)
|
||||||
reinstall_formula(f, build_from_source: true)
|
rescue FormulaInstallationAlreadyAttemptedError
|
||||||
rescue FormulaInstallationAlreadyAttemptedError
|
# We already attempted to reinstall f as part of the dependency tree of
|
||||||
# We already attempted to reinstall f as part of the dependency tree of
|
# another formula. In that case, don't generate an error, just move on.
|
||||||
# another formula. In that case, don't generate an error, just move on.
|
nil
|
||||||
nil
|
rescue CannotInstallFormulaError => e
|
||||||
rescue CannotInstallFormulaError => e
|
ofail e
|
||||||
ofail e
|
rescue BuildError => e
|
||||||
rescue BuildError => e
|
e.dump
|
||||||
e.dump
|
puts
|
||||||
puts
|
Homebrew.failed = true
|
||||||
Homebrew.failed = true
|
rescue DownloadError => e
|
||||||
rescue DownloadError => e
|
ofail e
|
||||||
ofail e
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -68,26 +68,22 @@ module Homebrew
|
|||||||
|
|
||||||
uses = formulae.select do |f|
|
uses = formulae.select do |f|
|
||||||
used_formulae.all? do |ff|
|
used_formulae.all? do |ff|
|
||||||
begin
|
deps = f.runtime_dependencies if only_installed_arg
|
||||||
deps = f.runtime_dependencies if only_installed_arg
|
deps ||= if recursive
|
||||||
deps ||= if recursive
|
recursive_includes(Dependency, f, includes, ignores)
|
||||||
recursive_includes(Dependency, f, includes, ignores)
|
else
|
||||||
else
|
reject_ignores(f.deps, ignores, includes)
|
||||||
reject_ignores(f.deps, ignores, includes)
|
|
||||||
end
|
|
||||||
|
|
||||||
deps.any? do |dep|
|
|
||||||
begin
|
|
||||||
dep.to_formula.full_name == ff.full_name
|
|
||||||
rescue
|
|
||||||
dep.name == ff.name
|
|
||||||
end
|
|
||||||
end
|
|
||||||
rescue FormulaUnavailableError
|
|
||||||
# Silently ignore this case as we don't care about things used in
|
|
||||||
# taps that aren't currently tapped.
|
|
||||||
next
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
deps.any? do |dep|
|
||||||
|
dep.to_formula.full_name == ff.full_name
|
||||||
|
rescue
|
||||||
|
dep.name == ff.name
|
||||||
|
end
|
||||||
|
rescue FormulaUnavailableError
|
||||||
|
# Silently ignore this case as we don't care about things used in
|
||||||
|
# taps that aren't currently tapped.
|
||||||
|
next
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -63,11 +63,9 @@ class DescriptionCacheStore < CacheStore
|
|||||||
return populate_if_empty! if database.empty?
|
return populate_if_empty! if database.empty?
|
||||||
|
|
||||||
formula_names.each do |name|
|
formula_names.each do |name|
|
||||||
begin
|
update!(name, Formula[name].desc)
|
||||||
update!(name, Formula[name].desc)
|
rescue FormulaUnavailableError, *FormulaVersions::IGNORED_EXCEPTIONS
|
||||||
rescue FormulaUnavailableError, *FormulaVersions::IGNORED_EXCEPTIONS
|
delete!(name)
|
||||||
delete!(name)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -434,16 +434,14 @@ module Homebrew
|
|||||||
|
|
||||||
def audit_conflicts
|
def audit_conflicts
|
||||||
formula.conflicts.each do |c|
|
formula.conflicts.each do |c|
|
||||||
begin
|
Formulary.factory(c.name)
|
||||||
Formulary.factory(c.name)
|
rescue TapFormulaUnavailableError
|
||||||
rescue TapFormulaUnavailableError
|
# Don't complain about missing cross-tap conflicts.
|
||||||
# Don't complain about missing cross-tap conflicts.
|
next
|
||||||
next
|
rescue FormulaUnavailableError
|
||||||
rescue FormulaUnavailableError
|
problem "Can't find conflicting formula #{c.name.inspect}."
|
||||||
problem "Can't find conflicting formula #{c.name.inspect}."
|
rescue TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError
|
||||||
rescue TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError
|
problem "Ambiguous conflicting formula #{c.name.inspect}."
|
||||||
problem "Ambiguous conflicting formula #{c.name.inspect}."
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -718,15 +718,13 @@ module Homebrew
|
|||||||
def check_for_unreadable_installed_formula
|
def check_for_unreadable_installed_formula
|
||||||
formula_unavailable_exceptions = []
|
formula_unavailable_exceptions = []
|
||||||
Formula.racks.each do |rack|
|
Formula.racks.each do |rack|
|
||||||
begin
|
Formulary.from_rack(rack)
|
||||||
Formulary.from_rack(rack)
|
rescue FormulaUnreadableError, FormulaClassUnavailableError,
|
||||||
rescue FormulaUnreadableError, FormulaClassUnavailableError,
|
TapFormulaUnreadableError, TapFormulaClassUnavailableError => e
|
||||||
TapFormulaUnreadableError, TapFormulaClassUnavailableError => e
|
formula_unavailable_exceptions << e
|
||||||
formula_unavailable_exceptions << e
|
rescue FormulaUnavailableError,
|
||||||
rescue FormulaUnavailableError,
|
TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError
|
||||||
TapFormulaAmbiguityError, TapFormulaWithOldnameAmbiguityError
|
nil
|
||||||
nil
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
return if formula_unavailable_exceptions.empty?
|
return if formula_unavailable_exceptions.empty?
|
||||||
|
|
||||||
|
@ -213,11 +213,9 @@ module SharedEnvExtension
|
|||||||
path.append(
|
path.append(
|
||||||
# user paths
|
# user paths
|
||||||
ORIGINAL_PATHS.map do |p|
|
ORIGINAL_PATHS.map do |p|
|
||||||
begin
|
p.realpath.to_s
|
||||||
p.realpath.to_s
|
rescue
|
||||||
rescue
|
nil
|
||||||
nil
|
|
||||||
end
|
|
||||||
end - %w[/usr/X11/bin /opt/X11/bin],
|
end - %w[/usr/X11/bin /opt/X11/bin],
|
||||||
)
|
)
|
||||||
self["PATH"] = path
|
self["PATH"] = path
|
||||||
|
@ -17,12 +17,10 @@ module Superenv
|
|||||||
def homebrew_extra_paths
|
def homebrew_extra_paths
|
||||||
paths = []
|
paths = []
|
||||||
paths += %w[binutils make].map do |f|
|
paths += %w[binutils make].map do |f|
|
||||||
begin
|
bin = Formula[f].opt_bin
|
||||||
bin = Formula[f].opt_bin
|
bin if bin.directory?
|
||||||
bin if bin.directory?
|
rescue FormulaUnavailableError
|
||||||
rescue FormulaUnavailableError
|
nil
|
||||||
nil
|
|
||||||
end
|
|
||||||
end.compact
|
end.compact
|
||||||
paths
|
paths
|
||||||
end
|
end
|
||||||
|
@ -387,11 +387,9 @@ class Formula
|
|||||||
return [] if versioned_formula?
|
return [] if versioned_formula?
|
||||||
|
|
||||||
Pathname.glob(path.to_s.gsub(/\.rb$/, "@*.rb")).map do |path|
|
Pathname.glob(path.to_s.gsub(/\.rb$/, "@*.rb")).map do |path|
|
||||||
begin
|
Formula[path.basename(".rb").to_s]
|
||||||
Formula[path.basename(".rb").to_s]
|
rescue FormulaUnavailableError
|
||||||
rescue FormulaUnavailableError
|
nil
|
||||||
nil
|
|
||||||
end
|
|
||||||
end.compact.sort
|
end.compact.sort
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1387,14 +1385,12 @@ class Formula
|
|||||||
# @private
|
# @private
|
||||||
def self.each
|
def self.each
|
||||||
files.each do |file|
|
files.each do |file|
|
||||||
begin
|
yield Formulary.factory(file)
|
||||||
yield Formulary.factory(file)
|
rescue => e
|
||||||
rescue => e
|
# Don't let one broken formula break commands. But do complain.
|
||||||
# Don't let one broken formula break commands. But do complain.
|
onoe "Failed to import: #{file}"
|
||||||
onoe "Failed to import: #{file}"
|
puts e
|
||||||
puts e
|
next
|
||||||
next
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1425,11 +1421,9 @@ class Formula
|
|||||||
# @private
|
# @private
|
||||||
def self.installed
|
def self.installed
|
||||||
@installed ||= racks.flat_map do |rack|
|
@installed ||= racks.flat_map do |rack|
|
||||||
begin
|
Formulary.from_rack(rack)
|
||||||
Formulary.from_rack(rack)
|
rescue
|
||||||
rescue
|
[]
|
||||||
[]
|
|
||||||
end
|
|
||||||
end.uniq(&:name)
|
end.uniq(&:name)
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -1568,11 +1562,9 @@ class Formula
|
|||||||
read_from_tab: read_from_tab,
|
read_from_tab: read_from_tab,
|
||||||
undeclared: undeclared,
|
undeclared: undeclared,
|
||||||
).map do |d|
|
).map do |d|
|
||||||
begin
|
d.to_formula
|
||||||
d.to_formula
|
rescue FormulaUnavailableError
|
||||||
rescue FormulaUnavailableError
|
nil
|
||||||
nil
|
|
||||||
end
|
|
||||||
end.compact
|
end.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -351,28 +351,26 @@ class FormulaInstaller
|
|||||||
return if ARGV.force?
|
return if ARGV.force?
|
||||||
|
|
||||||
conflicts = formula.conflicts.select do |c|
|
conflicts = formula.conflicts.select do |c|
|
||||||
begin
|
f = Formulary.factory(c.name)
|
||||||
f = Formulary.factory(c.name)
|
rescue TapFormulaUnavailableError
|
||||||
rescue TapFormulaUnavailableError
|
# If the formula name is a fully-qualified name let's silently
|
||||||
# If the formula name is a fully-qualified name let's silently
|
# ignore it as we don't care about things used in taps that aren't
|
||||||
# ignore it as we don't care about things used in taps that aren't
|
# currently tapped.
|
||||||
# currently tapped.
|
false
|
||||||
false
|
rescue FormulaUnavailableError => e
|
||||||
rescue FormulaUnavailableError => e
|
# If the formula name doesn't exist any more then complain but don't
|
||||||
# If the formula name doesn't exist any more then complain but don't
|
# stop installation from continuing.
|
||||||
# stop installation from continuing.
|
opoo <<~EOS
|
||||||
opoo <<~EOS
|
|
||||||
#{formula}: #{e.message}
|
#{formula}: #{e.message}
|
||||||
'conflicts_with \"#{c.name}\"' should be removed from #{formula.path.basename}.
|
'conflicts_with \"#{c.name}\"' should be removed from #{formula.path.basename}.
|
||||||
EOS
|
EOS
|
||||||
|
|
||||||
raise if ARGV.homebrew_developer?
|
raise if ARGV.homebrew_developer?
|
||||||
|
|
||||||
$stderr.puts "Please report this to the #{formula.tap} tap!"
|
$stderr.puts "Please report this to the #{formula.tap} tap!"
|
||||||
false
|
false
|
||||||
else
|
else
|
||||||
f.linked_keg.exist? && f.opt_prefix.exist?
|
f.linked_keg.exist? && f.opt_prefix.exist?
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
raise FormulaConflictError.new(formula, conflicts) unless conflicts.empty?
|
raise FormulaConflictError.new(formula, conflicts) unless conflicts.empty?
|
||||||
|
@ -106,11 +106,9 @@ require "PATH"
|
|||||||
|
|
||||||
ENV["HOMEBREW_PATH"] ||= ENV["PATH"]
|
ENV["HOMEBREW_PATH"] ||= ENV["PATH"]
|
||||||
ORIGINAL_PATHS = PATH.new(ENV["HOMEBREW_PATH"]).map do |p|
|
ORIGINAL_PATHS = PATH.new(ENV["HOMEBREW_PATH"]).map do |p|
|
||||||
begin
|
Pathname.new(p).expand_path
|
||||||
Pathname.new(p).expand_path
|
rescue
|
||||||
rescue
|
nil
|
||||||
nil
|
|
||||||
end
|
|
||||||
end.compact.freeze
|
end.compact.freeze
|
||||||
|
|
||||||
HOMEBREW_INTERNAL_COMMAND_ALIASES = {
|
HOMEBREW_INTERNAL_COMMAND_ALIASES = {
|
||||||
|
@ -22,17 +22,15 @@ module Homebrew
|
|||||||
|
|
||||||
def attempt_directory_creation
|
def attempt_directory_creation
|
||||||
Keg::MUST_EXIST_DIRECTORIES.each do |dir|
|
Keg::MUST_EXIST_DIRECTORIES.each do |dir|
|
||||||
begin
|
FileUtils.mkdir_p(dir) unless dir.exist?
|
||||||
FileUtils.mkdir_p(dir) unless dir.exist?
|
|
||||||
|
|
||||||
# Create these files to ensure that these directories aren't removed
|
# Create these files to ensure that these directories aren't removed
|
||||||
# by the Catalina installer.
|
# by the Catalina installer.
|
||||||
# (https://github.com/Homebrew/brew/issues/6263)
|
# (https://github.com/Homebrew/brew/issues/6263)
|
||||||
keep_file = dir/".keepme"
|
keep_file = dir/".keepme"
|
||||||
FileUtils.touch(keep_file) unless keep_file.exist?
|
FileUtils.touch(keep_file) unless keep_file.exist?
|
||||||
rescue
|
rescue
|
||||||
nil
|
nil
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -128,17 +128,15 @@ class Keg
|
|||||||
keg_names = kegs.select(&:optlinked?).map(&:name)
|
keg_names = kegs.select(&:optlinked?).map(&:name)
|
||||||
keg_formulae = []
|
keg_formulae = []
|
||||||
kegs_by_source = kegs.group_by do |keg|
|
kegs_by_source = kegs.group_by do |keg|
|
||||||
begin
|
|
||||||
# First, attempt to resolve the keg to a formula
|
# First, attempt to resolve the keg to a formula
|
||||||
# to get up-to-date name and tap information.
|
# to get up-to-date name and tap information.
|
||||||
f = keg.to_formula
|
f = keg.to_formula
|
||||||
keg_formulae << f
|
keg_formulae << f
|
||||||
[f.name, f.tap]
|
[f.name, f.tap]
|
||||||
rescue FormulaUnavailableError
|
rescue FormulaUnavailableError
|
||||||
# If the formula for the keg can't be found,
|
# If the formula for the keg can't be found,
|
||||||
# fall back to the information in the tab.
|
# fall back to the information in the tab.
|
||||||
[keg.name, keg.tab.tap]
|
[keg.name, keg.tab.tap]
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
all_required_kegs = Set.new
|
all_required_kegs = Set.new
|
||||||
|
@ -37,15 +37,13 @@ module Readall
|
|||||||
def valid_formulae?(formulae)
|
def valid_formulae?(formulae)
|
||||||
failed = false
|
failed = false
|
||||||
formulae.each do |file|
|
formulae.each do |file|
|
||||||
begin
|
Formulary.factory(file)
|
||||||
Formulary.factory(file)
|
rescue Interrupt
|
||||||
rescue Interrupt
|
raise
|
||||||
raise
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
onoe "Invalid formula: #{file}"
|
||||||
onoe "Invalid formula: #{file}"
|
puts e
|
||||||
puts e
|
failed = true
|
||||||
failed = true
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
!failed
|
!failed
|
||||||
end
|
end
|
||||||
|
@ -184,13 +184,11 @@ class SoftwareSpec
|
|||||||
def recursive_dependencies
|
def recursive_dependencies
|
||||||
deps_f = []
|
deps_f = []
|
||||||
recursive_dependencies = deps.map do |dep|
|
recursive_dependencies = deps.map do |dep|
|
||||||
begin
|
deps_f << dep.to_formula
|
||||||
deps_f << dep.to_formula
|
dep
|
||||||
dep
|
rescue TapFormulaUnavailableError
|
||||||
rescue TapFormulaUnavailableError
|
# Don't complain about missing cross-tap dependencies
|
||||||
# Don't complain about missing cross-tap dependencies
|
next
|
||||||
next
|
|
||||||
end
|
|
||||||
end.compact.uniq
|
end.compact.uniq
|
||||||
deps_f.compact.each do |f|
|
deps_f.compact.each do |f|
|
||||||
f.recursive_dependencies.each do |dep|
|
f.recursive_dependencies.each do |dep|
|
||||||
@ -386,11 +384,10 @@ class BottleSpecification
|
|||||||
def checksums
|
def checksums
|
||||||
tags = collector.keys.sort_by do |tag|
|
tags = collector.keys.sort_by do |tag|
|
||||||
# Sort non-MacOS tags below MacOS tags.
|
# Sort non-MacOS tags below MacOS tags.
|
||||||
begin
|
|
||||||
OS::Mac::Version.from_symbol tag
|
OS::Mac::Version.from_symbol tag
|
||||||
rescue ArgumentError
|
rescue ArgumentError
|
||||||
"0.#{tag}"
|
"0.#{tag}"
|
||||||
end
|
|
||||||
end
|
end
|
||||||
checksums = {}
|
checksums = {}
|
||||||
tags.reverse_each do |tag|
|
tags.reverse_each do |tag|
|
||||||
|
@ -148,13 +148,11 @@ class SystemCommand
|
|||||||
break if readable_sources.empty?
|
break if readable_sources.empty?
|
||||||
|
|
||||||
readable_sources.each do |source|
|
readable_sources.each do |source|
|
||||||
begin
|
line = source.readline_nonblock || ""
|
||||||
line = source.readline_nonblock || ""
|
type = (source == sources[0]) ? :stdout : :stderr
|
||||||
type = (source == sources[0]) ? :stdout : :stderr
|
yield(type, line)
|
||||||
yield(type, line)
|
rescue IO::WaitReadable, EOFError
|
||||||
rescue IO::WaitReadable, EOFError
|
next
|
||||||
next
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -199,15 +199,13 @@ shared_examples "#uninstall_phase or #zap_phase" do
|
|||||||
let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-#{directive}")) }
|
let(:cask) { Cask::CaskLoader.load(cask_path("with-#{artifact_dsl_key}-#{directive}")) }
|
||||||
|
|
||||||
around do |example|
|
around do |example|
|
||||||
begin
|
ENV["HOME"] = dir
|
||||||
ENV["HOME"] = dir
|
|
||||||
|
|
||||||
FileUtils.touch paths
|
FileUtils.touch paths
|
||||||
|
|
||||||
example.run
|
example.run
|
||||||
ensure
|
ensure
|
||||||
FileUtils.rm_f paths
|
FileUtils.rm_f paths
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -5,12 +5,10 @@ require_relative "shared_examples/invalid_option"
|
|||||||
|
|
||||||
describe Cask::Cmd::Create, :cask do
|
describe Cask::Cmd::Create, :cask do
|
||||||
around do |example|
|
around do |example|
|
||||||
begin
|
example.run
|
||||||
example.run
|
ensure
|
||||||
ensure
|
%w[new-cask additional-cask another-cask yet-another-cask local-caff].each do |cask|
|
||||||
%w[new-cask additional-cask another-cask yet-another-cask local-caff].each do |cask|
|
FileUtils.rm_f Cask::CaskLoader.path(cask)
|
||||||
FileUtils.rm_f Cask::CaskLoader.path(cask)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -473,18 +473,16 @@ describe Cask::DSL, :cask do
|
|||||||
end
|
end
|
||||||
|
|
||||||
it "does not include a trailing slash" do
|
it "does not include a trailing slash" do
|
||||||
begin
|
original_appdir = Cask::Config.global.appdir
|
||||||
original_appdir = Cask::Config.global.appdir
|
Cask::Config.global.appdir = "#{original_appdir}/"
|
||||||
Cask::Config.global.appdir = "#{original_appdir}/"
|
|
||||||
|
|
||||||
cask = Cask::Cask.new("appdir-trailing-slash") do
|
cask = Cask::Cask.new("appdir-trailing-slash") do
|
||||||
binary "#{appdir}/some/path"
|
binary "#{appdir}/some/path"
|
||||||
end
|
|
||||||
|
|
||||||
expect(cask.artifacts.first.source).to eq(original_appdir/"some/path")
|
|
||||||
ensure
|
|
||||||
Cask::Config.global.appdir = original_appdir
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
expect(cask.artifacts.first.source).to eq(original_appdir/"some/path")
|
||||||
|
ensure
|
||||||
|
Cask::Config.global.appdir = original_appdir
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -34,15 +34,13 @@ describe Homebrew::Cleanup do
|
|||||||
let(:lock_file) { Pathname.new("#{HOMEBREW_LOCKS}/foo") }
|
let(:lock_file) { Pathname.new("#{HOMEBREW_LOCKS}/foo") }
|
||||||
|
|
||||||
around do |example|
|
around do |example|
|
||||||
begin
|
FileUtils.touch ds_store
|
||||||
FileUtils.touch ds_store
|
FileUtils.touch lock_file
|
||||||
FileUtils.touch lock_file
|
|
||||||
|
|
||||||
example.run
|
example.run
|
||||||
ensure
|
ensure
|
||||||
FileUtils.rm_f ds_store
|
FileUtils.rm_f ds_store
|
||||||
FileUtils.rm_f lock_file
|
FileUtils.rm_f lock_file
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "::cleanup" do
|
describe "::cleanup" do
|
||||||
|
@ -33,15 +33,13 @@ RSpec.shared_context "custom internal commands" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
around do |example|
|
around do |example|
|
||||||
begin
|
cmds.each do |f|
|
||||||
cmds.each do |f|
|
FileUtils.touch f
|
||||||
FileUtils.touch f
|
|
||||||
end
|
|
||||||
|
|
||||||
example.run
|
|
||||||
ensure
|
|
||||||
FileUtils.rm_f cmds
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
example.run
|
||||||
|
ensure
|
||||||
|
FileUtils.rm_f cmds
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -9,17 +9,15 @@ end
|
|||||||
|
|
||||||
describe "brew style" do
|
describe "brew style" do
|
||||||
around do |example|
|
around do |example|
|
||||||
begin
|
FileUtils.ln_s HOMEBREW_LIBRARY_PATH, HOMEBREW_LIBRARY/"Homebrew"
|
||||||
FileUtils.ln_s HOMEBREW_LIBRARY_PATH, HOMEBREW_LIBRARY/"Homebrew"
|
FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop.yml", HOMEBREW_LIBRARY/".rubocop_audit.yml"
|
||||||
FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop.yml", HOMEBREW_LIBRARY/".rubocop_audit.yml"
|
FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop_shared.yml", HOMEBREW_LIBRARY/".rubocop_shared.yml"
|
||||||
FileUtils.ln_s HOMEBREW_LIBRARY_PATH.parent/".rubocop_shared.yml", HOMEBREW_LIBRARY/".rubocop_shared.yml"
|
|
||||||
|
|
||||||
example.run
|
example.run
|
||||||
ensure
|
ensure
|
||||||
FileUtils.rm_f HOMEBREW_LIBRARY/"Homebrew"
|
FileUtils.rm_f HOMEBREW_LIBRARY/"Homebrew"
|
||||||
FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop_audit.yml"
|
FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop_audit.yml"
|
||||||
FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop_shared.yml"
|
FileUtils.rm_f HOMEBREW_LIBRARY/".rubocop_shared.yml"
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
before do
|
before do
|
||||||
|
@ -73,20 +73,18 @@ describe Homebrew::Diagnostic::Checks do
|
|||||||
end
|
end
|
||||||
|
|
||||||
specify "#check_user_path_3" do
|
specify "#check_user_path_3" do
|
||||||
begin
|
sbin = HOMEBREW_PREFIX/"sbin"
|
||||||
sbin = HOMEBREW_PREFIX/"sbin"
|
ENV["HOMEBREW_PATH"] =
|
||||||
ENV["HOMEBREW_PATH"] =
|
"#{HOMEBREW_PREFIX}/bin#{File::PATH_SEPARATOR}" +
|
||||||
"#{HOMEBREW_PREFIX}/bin#{File::PATH_SEPARATOR}" +
|
ENV["HOMEBREW_PATH"].gsub(/(?:^|#{Regexp.escape(File::PATH_SEPARATOR)})#{Regexp.escape(sbin)}/, "")
|
||||||
ENV["HOMEBREW_PATH"].gsub(/(?:^|#{Regexp.escape(File::PATH_SEPARATOR)})#{Regexp.escape(sbin)}/, "")
|
(sbin/"something").mkpath
|
||||||
(sbin/"something").mkpath
|
|
||||||
|
|
||||||
expect(subject.check_user_path_1).to be nil
|
expect(subject.check_user_path_1).to be nil
|
||||||
expect(subject.check_user_path_2).to be nil
|
expect(subject.check_user_path_2).to be nil
|
||||||
expect(subject.check_user_path_3)
|
expect(subject.check_user_path_3)
|
||||||
.to match("Homebrew's sbin was not found in your PATH")
|
.to match("Homebrew's sbin was not found in your PATH")
|
||||||
ensure
|
ensure
|
||||||
sbin.rmtree
|
sbin.rmtree
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "#check_for_config_scripts" do
|
specify "#check_for_config_scripts" do
|
||||||
@ -103,18 +101,16 @@ describe Homebrew::Diagnostic::Checks do
|
|||||||
end
|
end
|
||||||
|
|
||||||
specify "#check_for_symlinked_cellar" do
|
specify "#check_for_symlinked_cellar" do
|
||||||
begin
|
HOMEBREW_CELLAR.rmtree
|
||||||
HOMEBREW_CELLAR.rmtree
|
|
||||||
|
|
||||||
mktmpdir do |path|
|
mktmpdir do |path|
|
||||||
FileUtils.ln_s path, HOMEBREW_CELLAR
|
FileUtils.ln_s path, HOMEBREW_CELLAR
|
||||||
|
|
||||||
expect(subject.check_for_symlinked_cellar).to match(path)
|
expect(subject.check_for_symlinked_cellar).to match(path)
|
||||||
end
|
|
||||||
ensure
|
|
||||||
HOMEBREW_CELLAR.unlink
|
|
||||||
HOMEBREW_CELLAR.mkpath
|
|
||||||
end
|
end
|
||||||
|
ensure
|
||||||
|
HOMEBREW_CELLAR.unlink
|
||||||
|
HOMEBREW_CELLAR.mkpath
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "#check_ld_vars catches LD vars" do
|
specify "#check_ld_vars catches LD vars" do
|
||||||
|
@ -1266,42 +1266,40 @@ describe Formula do
|
|||||||
let(:testball_repo) { HOMEBREW_PREFIX/"testball_repo" }
|
let(:testball_repo) { HOMEBREW_PREFIX/"testball_repo" }
|
||||||
|
|
||||||
example do
|
example do
|
||||||
begin
|
outdated_stable_prefix = HOMEBREW_CELLAR/"testball/1.0"
|
||||||
outdated_stable_prefix = HOMEBREW_CELLAR/"testball/1.0"
|
head_prefix_a = HOMEBREW_CELLAR/"testball/HEAD"
|
||||||
head_prefix_a = HOMEBREW_CELLAR/"testball/HEAD"
|
head_prefix_b = HOMEBREW_CELLAR/"testball/HEAD-aaaaaaa_1"
|
||||||
head_prefix_b = HOMEBREW_CELLAR/"testball/HEAD-aaaaaaa_1"
|
head_prefix_c = HOMEBREW_CELLAR/"testball/HEAD-18a7103"
|
||||||
head_prefix_c = HOMEBREW_CELLAR/"testball/HEAD-18a7103"
|
|
||||||
|
|
||||||
setup_tab_for_prefix(outdated_stable_prefix)
|
setup_tab_for_prefix(outdated_stable_prefix)
|
||||||
tab_a = setup_tab_for_prefix(head_prefix_a, versions: { "stable" => "1.0" })
|
tab_a = setup_tab_for_prefix(head_prefix_a, versions: { "stable" => "1.0" })
|
||||||
setup_tab_for_prefix(head_prefix_b)
|
setup_tab_for_prefix(head_prefix_b)
|
||||||
|
|
||||||
testball_repo.mkdir
|
testball_repo.mkdir
|
||||||
testball_repo.cd do
|
testball_repo.cd do
|
||||||
FileUtils.touch "LICENSE"
|
FileUtils.touch "LICENSE"
|
||||||
|
|
||||||
system("git", "init")
|
system("git", "init")
|
||||||
system("git", "add", "--all")
|
system("git", "add", "--all")
|
||||||
system("git", "commit", "-m", "Initial commit")
|
system("git", "commit", "-m", "Initial commit")
|
||||||
end
|
|
||||||
|
|
||||||
expect(f.outdated_kegs(fetch_head: true)).not_to be_empty
|
|
||||||
|
|
||||||
tab_a.source["versions"] = { "stable" => f.version.to_s }
|
|
||||||
tab_a.write
|
|
||||||
reset_outdated_kegs
|
|
||||||
expect(f.outdated_kegs(fetch_head: true)).not_to be_empty
|
|
||||||
|
|
||||||
head_prefix_a.rmtree
|
|
||||||
reset_outdated_kegs
|
|
||||||
expect(f.outdated_kegs(fetch_head: true)).not_to be_empty
|
|
||||||
|
|
||||||
setup_tab_for_prefix(head_prefix_c, source_modified_time: 1)
|
|
||||||
reset_outdated_kegs
|
|
||||||
expect(f.outdated_kegs(fetch_head: true)).to be_empty
|
|
||||||
ensure
|
|
||||||
testball_repo.rmtree if testball_repo.exist?
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
expect(f.outdated_kegs(fetch_head: true)).not_to be_empty
|
||||||
|
|
||||||
|
tab_a.source["versions"] = { "stable" => f.version.to_s }
|
||||||
|
tab_a.write
|
||||||
|
reset_outdated_kegs
|
||||||
|
expect(f.outdated_kegs(fetch_head: true)).not_to be_empty
|
||||||
|
|
||||||
|
head_prefix_a.rmtree
|
||||||
|
reset_outdated_kegs
|
||||||
|
expect(f.outdated_kegs(fetch_head: true)).not_to be_empty
|
||||||
|
|
||||||
|
setup_tab_for_prefix(head_prefix_c, source_modified_time: 1)
|
||||||
|
reset_outdated_kegs
|
||||||
|
expect(f.outdated_kegs(fetch_head: true)).to be_empty
|
||||||
|
ensure
|
||||||
|
testball_repo.rmtree if testball_repo.exist?
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -217,11 +217,9 @@ RSpec::Matchers.alias_matcher :a_string_containing, :include
|
|||||||
|
|
||||||
RSpec::Matchers.define :a_json_string do
|
RSpec::Matchers.define :a_json_string do
|
||||||
match do |actual|
|
match do |actual|
|
||||||
begin
|
JSON.parse(actual)
|
||||||
JSON.parse(actual)
|
true
|
||||||
true
|
rescue JSON::ParserError
|
||||||
rescue JSON::ParserError
|
false
|
||||||
false
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -66,10 +66,8 @@ end
|
|||||||
|
|
||||||
RSpec.configure do |config|
|
RSpec.configure do |config|
|
||||||
config.after do
|
config.after do
|
||||||
begin
|
FakeSystemCommand.verify_expectations!
|
||||||
FakeSystemCommand.verify_expectations!
|
ensure
|
||||||
ensure
|
FakeSystemCommand.clear
|
||||||
FakeSystemCommand.clear
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -41,14 +41,12 @@ RSpec.shared_context "integration test" do
|
|||||||
end
|
end
|
||||||
|
|
||||||
around do |example|
|
around do |example|
|
||||||
begin
|
(HOMEBREW_PREFIX/"bin").mkpath
|
||||||
(HOMEBREW_PREFIX/"bin").mkpath
|
FileUtils.touch HOMEBREW_PREFIX/"bin/brew"
|
||||||
FileUtils.touch HOMEBREW_PREFIX/"bin/brew"
|
|
||||||
|
|
||||||
example.run
|
example.run
|
||||||
ensure
|
ensure
|
||||||
FileUtils.rm_r HOMEBREW_PREFIX/"bin"
|
FileUtils.rm_r HOMEBREW_PREFIX/"bin"
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
# Generate unique ID to be able to
|
# Generate unique ID to be able to
|
||||||
@ -94,11 +92,9 @@ RSpec.shared_context "integration test" do
|
|||||||
simplecov_spec = Gem.loaded_specs["simplecov"]
|
simplecov_spec = Gem.loaded_specs["simplecov"]
|
||||||
specs = [simplecov_spec]
|
specs = [simplecov_spec]
|
||||||
simplecov_spec.runtime_dependencies.each do |dep|
|
simplecov_spec.runtime_dependencies.each do |dep|
|
||||||
begin
|
specs += dep.to_specs
|
||||||
specs += dep.to_specs
|
rescue Gem::LoadError => e
|
||||||
rescue Gem::LoadError => e
|
onoe e
|
||||||
onoe e
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
libs = specs.flat_map do |spec|
|
libs = specs.flat_map do |spec|
|
||||||
full_gem_path = spec.full_gem_path
|
full_gem_path = spec.full_gem_path
|
||||||
|
@ -267,14 +267,12 @@ describe SystemCommand do
|
|||||||
it "does not leak the secrets set by environment" do
|
it "does not leak the secrets set by environment" do
|
||||||
redacted_msg = /#{Regexp.escape("username:******")}/
|
redacted_msg = /#{Regexp.escape("username:******")}/
|
||||||
expect do
|
expect do
|
||||||
begin
|
ENV["PASSWORD"] = "hunter2"
|
||||||
ENV["PASSWORD"] = "hunter2"
|
described_class.run! "curl",
|
||||||
described_class.run! "curl",
|
args: %w[--user username:hunter2],
|
||||||
args: %w[--user username:hunter2],
|
verbose: true
|
||||||
verbose: true
|
ensure
|
||||||
ensure
|
ENV.delete "PASSWORD"
|
||||||
ENV.delete "PASSWORD"
|
|
||||||
end
|
|
||||||
end.to raise_error.with_message(redacted_msg).and output(redacted_msg).to_stdout
|
end.to raise_error.with_message(redacted_msg).and output(redacted_msg).to_stdout
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -61,27 +61,25 @@ describe Tap do
|
|||||||
end
|
end
|
||||||
|
|
||||||
specify "::fetch" do
|
specify "::fetch" do
|
||||||
begin
|
expect(described_class.fetch("Homebrew", "core")).to be_kind_of(CoreTap)
|
||||||
expect(described_class.fetch("Homebrew", "core")).to be_kind_of(CoreTap)
|
expect(described_class.fetch("Homebrew", "homebrew")).to be_kind_of(CoreTap)
|
||||||
expect(described_class.fetch("Homebrew", "homebrew")).to be_kind_of(CoreTap)
|
tap = described_class.fetch("Homebrew", "foo")
|
||||||
tap = described_class.fetch("Homebrew", "foo")
|
expect(tap).to be_kind_of(described_class)
|
||||||
expect(tap).to be_kind_of(described_class)
|
expect(tap.name).to eq("homebrew/foo")
|
||||||
expect(tap.name).to eq("homebrew/foo")
|
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
described_class.fetch("foo")
|
described_class.fetch("foo")
|
||||||
}.to raise_error(/Invalid tap name/)
|
}.to raise_error(/Invalid tap name/)
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
described_class.fetch("homebrew/homebrew/bar")
|
described_class.fetch("homebrew/homebrew/bar")
|
||||||
}.to raise_error(/Invalid tap name/)
|
}.to raise_error(/Invalid tap name/)
|
||||||
|
|
||||||
expect {
|
expect {
|
||||||
described_class.fetch("homebrew", "homebrew/baz")
|
described_class.fetch("homebrew", "homebrew/baz")
|
||||||
}.to raise_error(/Invalid tap name/)
|
}.to raise_error(/Invalid tap name/)
|
||||||
ensure
|
ensure
|
||||||
described_class.clear_cache
|
described_class.clear_cache
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "::from_path" do
|
describe "::from_path" do
|
||||||
@ -113,23 +111,21 @@ describe Tap do
|
|||||||
end
|
end
|
||||||
|
|
||||||
specify "#issues_url" do
|
specify "#issues_url" do
|
||||||
begin
|
t = described_class.new("someone", "foo")
|
||||||
t = described_class.new("someone", "foo")
|
path = Tap::TAP_DIRECTORY/"someone/homebrew-foo"
|
||||||
path = Tap::TAP_DIRECTORY/"someone/homebrew-foo"
|
path.mkpath
|
||||||
path.mkpath
|
cd path do
|
||||||
cd path do
|
system "git", "init"
|
||||||
system "git", "init"
|
system "git", "remote", "add", "origin",
|
||||||
system "git", "remote", "add", "origin",
|
"https://github.com/someone/homebrew-foo"
|
||||||
"https://github.com/someone/homebrew-foo"
|
|
||||||
end
|
|
||||||
expect(t.issues_url).to eq("https://github.com/someone/homebrew-foo/issues")
|
|
||||||
expect(subject.issues_url).to eq("https://github.com/Homebrew/homebrew-foo/issues")
|
|
||||||
|
|
||||||
(Tap::TAP_DIRECTORY/"someone/homebrew-no-git").mkpath
|
|
||||||
expect(described_class.new("someone", "no-git").issues_url).to be nil
|
|
||||||
ensure
|
|
||||||
path.parent.rmtree
|
|
||||||
end
|
end
|
||||||
|
expect(t.issues_url).to eq("https://github.com/someone/homebrew-foo/issues")
|
||||||
|
expect(subject.issues_url).to eq("https://github.com/Homebrew/homebrew-foo/issues")
|
||||||
|
|
||||||
|
(Tap::TAP_DIRECTORY/"someone/homebrew-no-git").mkpath
|
||||||
|
expect(described_class.new("someone", "no-git").issues_url).to be nil
|
||||||
|
ensure
|
||||||
|
path.parent.rmtree
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "files" do
|
specify "files" do
|
||||||
@ -272,53 +268,49 @@ describe Tap do
|
|||||||
end
|
end
|
||||||
|
|
||||||
specify "#install and #uninstall" do
|
specify "#install and #uninstall" do
|
||||||
begin
|
setup_tap_files
|
||||||
setup_tap_files
|
setup_git_repo
|
||||||
setup_git_repo
|
|
||||||
|
|
||||||
tap = described_class.new("Homebrew", "bar")
|
tap = described_class.new("Homebrew", "bar")
|
||||||
|
|
||||||
tap.install clone_target: subject.path/".git"
|
tap.install clone_target: subject.path/".git"
|
||||||
|
|
||||||
expect(tap).to be_installed
|
expect(tap).to be_installed
|
||||||
expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").to be_a_file
|
expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").to be_a_file
|
||||||
expect(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").to be_a_file
|
expect(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").to be_a_file
|
||||||
expect(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").to be_a_file
|
expect(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").to be_a_file
|
||||||
expect(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").to be_a_file
|
expect(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").to be_a_file
|
||||||
tap.uninstall
|
tap.uninstall
|
||||||
|
|
||||||
expect(tap).not_to be_installed
|
expect(tap).not_to be_installed
|
||||||
expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").not_to exist
|
expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").not_to exist
|
||||||
expect(HOMEBREW_PREFIX/"share/man/man1").not_to exist
|
expect(HOMEBREW_PREFIX/"share/man/man1").not_to exist
|
||||||
expect(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").not_to exist
|
expect(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").not_to exist
|
||||||
expect(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").not_to exist
|
expect(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").not_to exist
|
||||||
expect(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").not_to exist
|
expect(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").not_to exist
|
||||||
ensure
|
ensure
|
||||||
(HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist?
|
(HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist?
|
||||||
(HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist?
|
(HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist?
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "#link_completions_and_manpages" do
|
specify "#link_completions_and_manpages" do
|
||||||
begin
|
setup_tap_files
|
||||||
setup_tap_files
|
setup_git_repo
|
||||||
setup_git_repo
|
tap = described_class.new("Homebrew", "baz")
|
||||||
tap = described_class.new("Homebrew", "baz")
|
tap.install clone_target: subject.path/".git"
|
||||||
tap.install clone_target: subject.path/".git"
|
(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete
|
||||||
(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").delete
|
(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").delete
|
||||||
(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").delete
|
(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").delete
|
||||||
(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").delete
|
(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").delete
|
||||||
(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").delete
|
tap.link_completions_and_manpages
|
||||||
tap.link_completions_and_manpages
|
expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").to be_a_file
|
||||||
expect(HOMEBREW_PREFIX/"share/man/man1/brew-tap-cmd.1").to be_a_file
|
expect(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").to be_a_file
|
||||||
expect(HOMEBREW_PREFIX/"etc/bash_completion.d/brew-tap-cmd").to be_a_file
|
expect(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").to be_a_file
|
||||||
expect(HOMEBREW_PREFIX/"share/zsh/site-functions/_brew-tap-cmd").to be_a_file
|
expect(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").to be_a_file
|
||||||
expect(HOMEBREW_PREFIX/"share/fish/vendor_completions.d/brew-tap-cmd.fish").to be_a_file
|
tap.uninstall
|
||||||
tap.uninstall
|
ensure
|
||||||
ensure
|
(HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist?
|
||||||
(HOMEBREW_PREFIX/"etc").rmtree if (HOMEBREW_PREFIX/"etc").exist?
|
(HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist?
|
||||||
(HOMEBREW_PREFIX/"share").rmtree if (HOMEBREW_PREFIX/"share").exist?
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
specify "#pin and #unpin" do
|
specify "#pin and #unpin" do
|
||||||
|
@ -50,13 +50,11 @@ module Homebrew
|
|||||||
|
|
||||||
method = instance_method(name)
|
method = instance_method(name)
|
||||||
define_method(name) do |*args, &block|
|
define_method(name) do |*args, &block|
|
||||||
begin
|
time = Time.now
|
||||||
time = Time.now
|
method.bind(self).call(*args, &block)
|
||||||
method.bind(self).call(*args, &block)
|
ensure
|
||||||
ensure
|
$times[name] ||= 0
|
||||||
$times[name] ||= 0
|
$times[name] += Time.now - time
|
||||||
$times[name] += Time.now - time
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
@ -388,11 +386,9 @@ module Kernel
|
|||||||
|
|
||||||
def paths
|
def paths
|
||||||
@paths ||= PATH.new(ENV["HOMEBREW_PATH"]).map do |p|
|
@paths ||= PATH.new(ENV["HOMEBREW_PATH"]).map do |p|
|
||||||
begin
|
File.expand_path(p).chomp("/")
|
||||||
File.expand_path(p).chomp("/")
|
rescue ArgumentError
|
||||||
rescue ArgumentError
|
onoe "The following PATH component is invalid: #{p}"
|
||||||
onoe "The following PATH component is invalid: #{p}"
|
|
||||||
end
|
|
||||||
end.uniq.compact
|
end.uniq.compact
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -32,31 +32,29 @@ module Utils
|
|||||||
read, write = IO.pipe
|
read, write = IO.pipe
|
||||||
|
|
||||||
pid = fork do
|
pid = fork do
|
||||||
begin
|
ENV["HOMEBREW_ERROR_PIPE"] = server.path
|
||||||
ENV["HOMEBREW_ERROR_PIPE"] = server.path
|
server.close
|
||||||
server.close
|
read.close
|
||||||
read.close
|
write.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
|
||||||
write.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
|
yield
|
||||||
yield
|
rescue Exception => e # rubocop:disable Lint/RescueException
|
||||||
rescue Exception => e # rubocop:disable Lint/RescueException
|
error_hash = JSON.parse e.to_json
|
||||||
error_hash = JSON.parse e.to_json
|
|
||||||
|
|
||||||
# Special case: We need to recreate ErrorDuringExecutions
|
# Special case: We need to recreate ErrorDuringExecutions
|
||||||
# for proper error messages and because other code expects
|
# for proper error messages and because other code expects
|
||||||
# to rescue them further down.
|
# to rescue them further down.
|
||||||
if e.is_a?(ErrorDuringExecution)
|
if e.is_a?(ErrorDuringExecution)
|
||||||
error_hash["cmd"] = e.cmd
|
error_hash["cmd"] = e.cmd
|
||||||
error_hash["status"] = e.status.exitstatus
|
error_hash["status"] = e.status.exitstatus
|
||||||
error_hash["output"] = e.output
|
error_hash["output"] = e.output
|
||||||
end
|
|
||||||
|
|
||||||
write.puts error_hash.to_json
|
|
||||||
write.close
|
|
||||||
|
|
||||||
exit!
|
|
||||||
else
|
|
||||||
exit!(true)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
write.puts error_hash.to_json
|
||||||
|
write.close
|
||||||
|
|
||||||
|
exit!
|
||||||
|
else
|
||||||
|
exit!(true)
|
||||||
end
|
end
|
||||||
|
|
||||||
ignore_interrupts(:quietly) do # the child will receive the interrupt and marshal it back
|
ignore_interrupts(:quietly) do # the child will receive the interrupt and marshal it back
|
||||||
|
Loading…
x
Reference in New Issue
Block a user