Skip to content

Commit

Permalink
cmd/upgrade: Error when attempting to explicitly upgrade a pinned pkg
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
apainintheneck committed Dec 13, 2023
1 parent b3a6e59 commit 9a00f27
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion Library/Homebrew/cmd/upgrade.rb
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,10 @@ def upgrade_outdated_formulae(formulae, args:)
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

Expand Down

0 comments on commit 9a00f27

Please sign in to comment.