2024-04-01 09:44:14 -07:00
|
|
|
# typed: strict
|
2019-04-19 15:38:03 +09:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2024-04-01 09:44:14 -07:00
|
|
|
require "abstract_command"
|
2015-08-03 13:09:07 +01:00
|
|
|
require "formula"
|
2013-03-11 16:41:08 +01:00
|
|
|
|
2014-06-18 22:41:47 -05:00
|
|
|
module Homebrew
|
2024-04-01 09:44:14 -07:00
|
|
|
module Cmd
|
|
|
|
class Pin < AbstractCommand
|
|
|
|
cmd_args do
|
|
|
|
description <<~EOS
|
|
|
|
Pin the specified <formula>, preventing them from being upgraded when
|
|
|
|
issuing the `brew upgrade` <formula> command. See also `unpin`.
|
2016-09-26 01:44:51 +02:00
|
|
|
|
2024-04-01 09:44:14 -07:00
|
|
|
*Note:* Other packages which depend on newer versions of a pinned formula
|
|
|
|
might not install or run correctly.
|
|
|
|
EOS
|
2023-12-05 23:11:59 -08:00
|
|
|
|
2024-04-01 09:44:14 -07:00
|
|
|
named_args :installed_formula, min: 1
|
|
|
|
end
|
2018-11-11 20:06:40 +05:30
|
|
|
|
2024-04-01 09:44:14 -07:00
|
|
|
sig { override.void }
|
|
|
|
def run
|
|
|
|
args.named.to_resolved_formulae.each do |f|
|
|
|
|
if f.pinned?
|
2025-07-04 13:28:54 -07:00
|
|
|
ofail "#{f.name} already pinned"
|
2024-04-01 09:44:14 -07:00
|
|
|
elsif !f.pinnable?
|
2025-07-04 13:28:54 -07:00
|
|
|
ofail "#{f.name} not installed"
|
2024-04-01 09:44:14 -07:00
|
|
|
else
|
|
|
|
f.pin
|
|
|
|
end
|
|
|
|
end
|
2013-04-16 01:43:26 -05:00
|
|
|
end
|
2013-03-11 16:41:08 +01:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|