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.
This commit is contained in:
apainintheneck 2023-12-13 00:15:00 -08:00
parent b3a6e59f96
commit 9a00f2795d

View File

@ -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