From 9a00f2795d9eca48385a5222d953787b0269f050 Mon Sep 17 00:00:00 2001 From: apainintheneck Date: Wed, 13 Dec 2023 00:15:00 -0800 Subject: [PATCH] cmd/upgrade: Error when attempting to explicitly upgrade a pinned pkg The idea here is that it should be expected that `brew upgrade` will not upgrade pinned packages but will attempt to upgrade everything else. For that reason, it will only show a warning about pinned packages in that case. If, on the other hand, you pass the name of a pinned package explicitly to the upgrade command, like in `brew upgrade PINNED`, we want to show an error since we cannot upgrade that package until it gets unpinned. --- Library/Homebrew/cmd/upgrade.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Library/Homebrew/cmd/upgrade.rb b/Library/Homebrew/cmd/upgrade.rb index d995283ebb..8ce28ea651 100644 --- a/Library/Homebrew/cmd/upgrade.rb +++ b/Library/Homebrew/cmd/upgrade.rb @@ -196,7 +196,10 @@ module Homebrew end if pinned.any? - opoo "Not upgrading #{pinned.count} pinned #{Utils.pluralize("package", pinned.count)}:" + Kernel.public_send( + formulae.any? ? :ofail : :opoo, # only fail when pinned formulae are named explicitly + "Not upgrading #{pinned.count} pinned #{Utils.pluralize("package", pinned.count)}:", + ) puts pinned.map { |f| "#{f.full_specified_name} #{f.pkg_version}" } * ", " end