mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
Port Homebrew::Cmd::Pin
This commit is contained in:
parent
7725fc62d4
commit
c1b1c11a8c
@ -1,15 +1,13 @@
|
|||||||
# typed: true
|
# typed: strict
|
||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "abstract_command"
|
||||||
require "formula"
|
require "formula"
|
||||||
require "cli/parser"
|
|
||||||
|
|
||||||
module Homebrew
|
module Homebrew
|
||||||
module_function
|
module Cmd
|
||||||
|
class Pin < AbstractCommand
|
||||||
sig { returns(CLI::Parser) }
|
cmd_args do
|
||||||
def pin_args
|
|
||||||
Homebrew::CLI::Parser.new do
|
|
||||||
description <<~EOS
|
description <<~EOS
|
||||||
Pin the specified <formula>, preventing them from being upgraded when
|
Pin the specified <formula>, preventing them from being upgraded when
|
||||||
issuing the `brew upgrade` <formula> command. See also `unpin`.
|
issuing the `brew upgrade` <formula> command. See also `unpin`.
|
||||||
@ -20,11 +18,9 @@ module Homebrew
|
|||||||
|
|
||||||
named_args :installed_formula, min: 1
|
named_args :installed_formula, min: 1
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
def pin
|
|
||||||
args = pin_args.parse
|
|
||||||
|
|
||||||
|
sig { override.void }
|
||||||
|
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"
|
opoo "#{f.name} already pinned"
|
||||||
@ -35,4 +31,6 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
# frozen_string_literal: true
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "cmd/pin"
|
||||||
require "cmd/shared_examples/args_parse"
|
require "cmd/shared_examples/args_parse"
|
||||||
|
|
||||||
RSpec.describe "brew pin" do
|
RSpec.describe Homebrew::Cmd::Pin do
|
||||||
it_behaves_like "parseable arguments"
|
it_behaves_like "parseable arguments"
|
||||||
|
|
||||||
it "pins a Formula's version", :integration_test do
|
it "pins a Formula's version", :integration_test do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user