diff --git a/Library/Homebrew/PATH.rb b/Library/Homebrew/PATH.rb index 20b83d0d36..3d5ca1f332 100644 --- a/Library/Homebrew/PATH.rb +++ b/Library/Homebrew/PATH.rb @@ -67,9 +67,8 @@ class PATH sig { params(other: T.untyped).returns(T::Boolean) } def ==(other) - if other.respond_to?(:to_ary) && to_ary == other.to_ary - true - elsif other.respond_to?(:to_str) && to_str == other.to_str + if other.respond_to?(:to_ary) && to_ary == other.to_ary || + other.respond_to?(:to_str) && to_str == other.to_str true else false diff --git a/Library/Homebrew/build.rb b/Library/Homebrew/build.rb index f7c4274874..b24fef7525 100644 --- a/Library/Homebrew/build.rb +++ b/Library/Homebrew/build.rb @@ -53,11 +53,7 @@ class Build def expand_reqs formula.recursive_requirements do |dependent, req| build = effective_build_options_for(dependent) - if req.prune_from_option?(build) - Requirement.prune - elsif req.prune_if_build_and_not_dependent?(dependent, formula) - Requirement.prune - elsif req.test? + if req.prune_from_option?(build) || req.prune_if_build_and_not_dependent?(dependent, formula) || req.test? Requirement.prune end end @@ -66,14 +62,10 @@ class Build def expand_deps formula.recursive_dependencies do |dependent, dep| build = effective_build_options_for(dependent) - if dep.prune_from_option?(build) - Dependency.prune - elsif dep.prune_if_build_and_not_dependent?(dependent, formula) + if dep.prune_from_option?(build) || dep.prune_if_build_and_not_dependent?(dependent, formula) || dep.test? Dependency.prune elsif dep.build? Dependency.keep_but_prune_recursive_deps - elsif dep.test? - Dependency.prune end end end diff --git a/Library/Homebrew/cask/cmd/audit.rb b/Library/Homebrew/cask/cmd/audit.rb index dcfd98741c..4489a80aa3 100644 --- a/Library/Homebrew/cask/cmd/audit.rb +++ b/Library/Homebrew/cask/cmd/audit.rb @@ -60,12 +60,10 @@ module Cask options[:quarantine] = true if options[:quarantine].nil? casks = args.named.flat_map do |name| - if File.exist?(name) + if File.exist?(name) && name.count("/") != 1 name - elsif name.count("/") == 1 - Tap.fetch(name).cask_files else - name + Tap.fetch(name).cask_files end end casks = casks.map { |c| CaskLoader.load(c, config: Config.from_args(args)) } diff --git a/Library/Homebrew/cleaner.rb b/Library/Homebrew/cleaner.rb index 070f5cb213..238a1f0948 100644 --- a/Library/Homebrew/cleaner.rb +++ b/Library/Homebrew/cleaner.rb @@ -93,18 +93,15 @@ class Cleaner next if path.directory? - if path.extname == ".la" - path.unlink - elsif path.symlink? - # Skip it. - elsif path.basename.to_s == "perllocal.pod" - # Both this file & the .packlist one below are completely unnecessary + files_to_skip = %w[perllocal.pod .packlist] + if path.extname == ".la" || (!path.symlink? && files_to_skip.include?(path.basename.to_s)) + # Both the `perllocal.pod` & `.packlist` files are completely unnecessary # to package & causes pointless conflict with other formulae. They are # removed by Debian, Arch & MacPorts amongst other packagers as well. # The files are created as part of installing any Perl module. path.unlink - elsif path.basename.to_s == ".packlist" # Hidden file, not file extension! - path.unlink + elsif path.symlink? + # Skip it. else # Set permissions for executables and non-executables perms = if executable_path?(path) diff --git a/Library/Homebrew/dependency_collector.rb b/Library/Homebrew/dependency_collector.rb index 356437c7a9..c375139955 100644 --- a/Library/Homebrew/dependency_collector.rb +++ b/Library/Homebrew/dependency_collector.rb @@ -115,8 +115,6 @@ class DependencyCollector def parse_string_spec(spec, tags) if spec.match?(HOMEBREW_TAP_FORMULA_REGEX) TapDependency.new(spec, tags) - elsif tags.empty? - Dependency.new(spec, tags) else Dependency.new(spec, tags) end diff --git a/Library/Homebrew/download_strategy.rb b/Library/Homebrew/download_strategy.rb index eb4a48389b..624216d3b2 100644 --- a/Library/Homebrew/download_strategy.rb +++ b/Library/Homebrew/download_strategy.rb @@ -1233,22 +1233,20 @@ class DownloadStrategyDetector when %r{^https?://(.+?\.)?googlecode\.com/svn}, %r{^https?://svn\.}, %r{^svn://}, - %r{^https?://(.+?\.)?sourceforge\.net/svnroot/} + %r{^https?://(.+?\.)?sourceforge\.net/svnroot/}, + %r{^svn\+http://}, + %r{^http://svn\.apache\.org/repos/} SubversionDownloadStrategy when %r{^cvs://} CVSDownloadStrategy when %r{^hg://}, - %r{^https?://(.+?\.)?googlecode\.com/hg} + %r{^https?://(.+?\.)?googlecode\.com/hg}, + %r{^https?://(.+?\.)?sourceforge\.net/hgweb/} MercurialDownloadStrategy when %r{^bzr://} BazaarDownloadStrategy when %r{^fossil://} FossilDownloadStrategy - when %r{^svn\+http://}, - %r{^http://svn\.apache\.org/repos/} - SubversionDownloadStrategy - when %r{^https?://(.+?\.)?sourceforge\.net/hgweb/} - MercurialDownloadStrategy else CurlDownloadStrategy end diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index 10e5347b86..5584605ce7 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1270,10 +1270,8 @@ class Formula break end - if current_version - [] - elsif (head_version = latest_head_version) && - !head_version_outdated?(head_version, fetch_head: fetch_head) + if current_version || + (latest_head_version && !head_version_outdated?(latest_head_version, fetch_head: fetch_head)) [] else all_kegs += old_installed_formulae.flat_map(&:installed_kegs) diff --git a/Library/Homebrew/formula_installer.rb b/Library/Homebrew/formula_installer.rb index 364aed2746..9be7893ba7 100644 --- a/Library/Homebrew/formula_installer.rb +++ b/Library/Homebrew/formula_installer.rb @@ -534,13 +534,10 @@ class FormulaInstaller keep_build_test ||= req.test? && include_test? && dependent == f keep_build_test ||= req.build? && !install_bottle_for_dependent && !dependent.latest_version_installed? - if req.prune_from_option?(build) - Requirement.prune - elsif req.satisfied?(env: env, cc: cc, build_bottle: @build_bottle, bottle_arch: bottle_arch) - Requirement.prune - elsif (req.build? || req.test?) && !keep_build_test - Requirement.prune - elsif (dep = formula_deps_map[dependent.name]) && dep.build? + if req.prune_from_option?(build) || + req.satisfied?(env: env, cc: cc, build_bottle: @build_bottle, bottle_arch: bottle_arch) || + ((req.build? || req.test?) && !keep_build_test) || + (formula_deps_map.key?(dependent.name) && formula_deps_map[dependent.name].build?) Requirement.prune else unsatisfied_reqs[dependent] << req @@ -569,9 +566,8 @@ class FormulaInstaller keep_build_test ||= dep.test? && include_test? && include_test_formulae.include?(dependent.full_name) keep_build_test ||= dep.build? && !install_bottle_for?(dependent, build) && !dependent.latest_version_installed? - if dep.prune_from_option?(build) - Dependency.prune - elsif (dep.build? || dep.test?) && !keep_build_test + if dep.prune_from_option?(build) || + ((dep.build? || dep.test?) && !keep_build_test) Dependency.prune elsif dep.satisfied?(inherited_options[dep.name]) Dependency.skip diff --git a/Library/Homebrew/keg.rb b/Library/Homebrew/keg.rb index d968c0c5e3..456b769621 100644 --- a/Library/Homebrew/keg.rb +++ b/Library/Homebrew/keg.rb @@ -482,18 +482,18 @@ class Keg link_dir("share", **options) do |relative_path| case relative_path.to_s - when "locale/locale.alias" then :skip_file when INFOFILE_RX then :info - when LOCALEDIR_RX then :mkpath - when %r{^icons/.*/icon-theme\.cache$} then :skip_file - # all icons subfolders should also mkpath - when %r{^icons/} then :mkpath - when /^zsh/ then :mkpath - when /^fish/ then :mkpath - # Lua, Lua51, Lua53 all need the same handling. - when %r{^lua/} then :mkpath - when %r{^guile/} then :mkpath - when *SHARE_PATHS then :mkpath + when "locale/locale.alias", + %r{^icons/.*/icon-theme\.cache$} + :skip_file + when LOCALEDIR_RX, + %r{^icons/}, # all icons subfolders should also mkpath + /^zsh/, + /^fish/, + %r{^lua/}, # Lua, Lua51, Lua53 all need the same handling. + %r{^guile/}, + *SHARE_PATHS + :mkpath else :link end end @@ -501,24 +501,22 @@ class Keg link_dir("lib", **options) do |relative_path| case relative_path.to_s when "charset.alias" then :skip_file - # pkg-config database gets explicitly created - when "pkgconfig" then :mkpath - # cmake database gets explicitly created - when "cmake" then :mkpath - # lib/language folders also get explicitly created - when "dtrace" then :mkpath - when /^gdk-pixbuf/ then :mkpath - when "ghc" then :mkpath - when /^gio/ then :mkpath - when "lua" then :mkpath - when /^mecab/ then :mkpath - when /^node/ then :mkpath - when /^ocaml/ then :mkpath - when /^perl5/ then :mkpath - when "php" then :mkpath - when /^python[23]\.\d/ then :mkpath - when /^R/ then :mkpath - when /^ruby/ then :mkpath + when "pkgconfig", # pkg-config database gets explicitly created + "cmake", # cmake database gets explicitly created + "dtrace", # lib/language folders also get explicitly created + /^gdk-pixbuf/, + "ghc", + /^gio/, + "lua", + /^mecab/, + /^node/, + /^ocaml/, + /^perl5/, + "php", + /^python[23]\.\d/, + /^R/, + /^ruby/, + :mkpath # Everything else is symlinked to the cellar else :link end diff --git a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb index 3d18361e9b..306b33fa9d 100644 --- a/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb +++ b/Library/Homebrew/test/support/helper/spec/shared_context/integration_test.rb @@ -151,7 +151,7 @@ RSpec.shared_context "integration test" do # something here RUBY - when "foo" + when "foo", "patchelf" content = <<~RUBY url "https://brew.sh/#{name}-1.0" RUBY @@ -160,11 +160,6 @@ RSpec.shared_context "integration test" do url "https://brew.sh/#{name}-1.0" depends_on "foo" RUBY - when "patchelf" - content = <<~RUBY - url "https://brew.sh/#{name}-1.0" - RUBY - when "package_license" content = <<~RUBY url "https://brew.sh/#patchelf-1.0" diff --git a/Library/Homebrew/upgrade.rb b/Library/Homebrew/upgrade.rb index 1fa4e8313f..15602d126a 100644 --- a/Library/Homebrew/upgrade.rb +++ b/Library/Homebrew/upgrade.rb @@ -103,14 +103,12 @@ module Homebrew # We already attempted to upgrade f as part of the dependency tree of # another formula. In that case, don't generate an error, just move on. nil - rescue CannotInstallFormulaError => e + rescue CannotInstallFormulaError, DownloadError => e ofail e rescue BuildError => e e.dump(verbose: args.verbose?) puts Homebrew.failed = true - rescue DownloadError => e - ofail e ensure # restore previous installation state if build failed begin @@ -241,14 +239,12 @@ module Homebrew # 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. nil - rescue CannotInstallFormulaError => e + rescue CannotInstallFormulaError, DownloadError => e ofail e rescue BuildError => e e.dump(verbose: args.verbose?) puts Homebrew.failed = true - rescue DownloadError => e - ofail e end end diff --git a/Library/Homebrew/version.rb b/Library/Homebrew/version.rb index 08c0d76021..547c0c9850 100644 --- a/Library/Homebrew/version.rb +++ b/Library/Homebrew/version.rb @@ -516,7 +516,7 @@ class Version l += 1 r += 1 next - elsif a.numeric? && b.numeric? + elsif a.numeric? == b.numeric? return a <=> b elsif a.numeric? return 1 if a > NULL_TOKEN @@ -526,8 +526,6 @@ class Version return -1 if b > NULL_TOKEN r += 1 - else - return a <=> b end end