Exit non-zero when pinning uninstalled formula

This commit is contained in:
Douglas Eichelberger 2025-07-04 13:28:54 -07:00
parent b57557dc3d
commit f4bcda325a
No known key found for this signature in database
GPG Key ID: F90193CBD547EB81
2 changed files with 8 additions and 2 deletions

View File

@ -23,9 +23,9 @@ module Homebrew
def run def run
args.named.to_resolved_formulae.each do |f| args.named.to_resolved_formulae.each do |f|
if f.pinned? if f.pinned?
opoo "#{f.name} already pinned" ofail "#{f.name} already pinned"
elsif !f.pinnable? elsif !f.pinnable?
onoe "#{f.name} not installed" ofail "#{f.name} not installed"
else else
f.pin f.pin
end end

View File

@ -11,4 +11,10 @@ RSpec.describe Homebrew::Cmd::Pin do
expect { brew "pin", "testball" }.to be_a_success expect { brew "pin", "testball" }.to be_a_success
end end
it "fails with an uninstalled Formula", :integration_test do
setup_test_formula "testball"
expect { brew "pin", "testball" }.to be_a_failure
end
end end