From ca5f6026eddbc0037f875b3db4a72a606a7d3c42 Mon Sep 17 00:00:00 2001 From: Rylan Polster Date: Mon, 5 Jul 2021 11:29:27 -0400 Subject: [PATCH] Fix tests --- Library/Homebrew/cmd/outdated.rb | 2 +- Library/Homebrew/cmd/reinstall.rb | 2 +- Library/Homebrew/cmd/upgrade.rb | 2 +- Library/Homebrew/formula.rb | 2 +- Library/Homebrew/utils/bottle_api.rb | 3 +++ 5 files changed, 7 insertions(+), 4 deletions(-) diff --git a/Library/Homebrew/cmd/outdated.rb b/Library/Homebrew/cmd/outdated.rb index b888dcd8cc..801b3e8370 100644 --- a/Library/Homebrew/cmd/outdated.rb +++ b/Library/Homebrew/cmd/outdated.rb @@ -100,7 +100,7 @@ module Homebrew elsif f.tap.present? f.pkg_version.to_s else - Utils::BottleAPI.latest_pkg_version(f.name).to_s + Utils::BottleAPI.latest_pkg_version(f.name)&.to_s || f.pkg_version.to_s end outdated_versions = outdated_kegs.group_by { |keg| Formulary.from_keg(keg).full_name } diff --git a/Library/Homebrew/cmd/reinstall.rb b/Library/Homebrew/cmd/reinstall.rb index e03d522e1d..9dc0b25e40 100644 --- a/Library/Homebrew/cmd/reinstall.rb +++ b/Library/Homebrew/cmd/reinstall.rb @@ -88,7 +88,7 @@ module Homebrew args.named.each do |name| formula = Formulary.factory(name) next unless formula.any_version_installed? - next if formula.tap.present? && !formula.tap.installed? + next if formula.tap.present? next unless Utils::BottleAPI.bottle_available?(name) Utils::BottleAPI.fetch_bottles(name) diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index 64c06aedd5..ded57bc74d 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -161,7 +161,7 @@ module Homebrew if ENV["HOMEBREW_JSON_CORE"].present? && !CoreTap.instance.installed? formulae_to_install.map! do |formula| - next formula if formula.tap.present? && formula.tap.installed? + next formula if formula.tap.present? next formula unless Utils::BottleAPI.bottle_available?(formula.name) Utils::BottleAPI.fetch_bottles(formula.name) diff --git a/Library/Homebrew/formula.rb b/Library/Homebrew/formula.rb index db7e8faf43..8c6bda7216 100644 --- a/Library/Homebrew/formula.rb +++ b/Library/Homebrew/formula.rb @@ -1328,7 +1328,7 @@ class Formula latest_version = if tap.present? pkg_version else - Utils::BottleAPI.latest_pkg_version name + Utils::BottleAPI.latest_pkg_version(name) || pkg_version end installed_kegs.each do |keg| diff --git a/Library/Homebrew/utils/bottle_api.rb b/Library/Homebrew/utils/bottle_api.rb index 3d42ac083d..838367f57b 100644 --- a/Library/Homebrew/utils/bottle_api.rb +++ b/Library/Homebrew/utils/bottle_api.rb @@ -46,6 +46,9 @@ module Utils output = Utils::Curl.curl_output("--fail", FORMULAE_BREW_SH_VERSIONS_API_URL) JSON.parse(output.stdout) end + + return unless @formula_versions.key? name + PkgVersion.new(@formula_versions[name]["version"], @formula_versions[name]["revision"]) end