formula/cask: add symbol support to no_autobump! method
Signed-off-by: botantony <antonsm21@gmail.com>
This commit is contained in:
parent
5c032d3616
commit
79cf39fc1d
7
Library/Homebrew/autobump_constants.rb
Normal file
7
Library/Homebrew/autobump_constants.rb
Normal file
@ -0,0 +1,7 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
# TODO: add more reasons here
|
||||
NO_AUTOBUMP_REASONS_LIST = T.let({
|
||||
incompatible_version_format: "incompatible version format",
|
||||
}.freeze, T::Hash[Symbol, String])
|
||||
@ -1,6 +1,7 @@
|
||||
# typed: true # rubocop:todo Sorbet/StrictSigil
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "autobump_constants"
|
||||
require "locale"
|
||||
require "lazy_object"
|
||||
require "livecheck"
|
||||
@ -547,14 +548,18 @@ module Cask
|
||||
end
|
||||
|
||||
def no_autobump!(because:)
|
||||
raise ArgumentError, "`because` argument must be a string!" unless because.is_a?(String)
|
||||
if !because.is_a?(String) && (!because.is_a?(Symbol) || !NO_AUTOBUMP_REASONS_LIST.key?(because))
|
||||
raise ArgumentError, "'because' argument should use valid symbol or a string!"
|
||||
end
|
||||
|
||||
if !@cask.allow_reassignment && @no_autobump_defined
|
||||
raise CaskInvalidError.new(cask, "'no_autobump_defined' stanza may only appear once.")
|
||||
end
|
||||
|
||||
@no_autobump_defined = true
|
||||
@no_autobump_message = because
|
||||
# TODO: add symbol support when a list of common reasons is ready.
|
||||
# At this moment just convert symbols to a string
|
||||
@no_autobump_message = because.to_s
|
||||
@autobump = false
|
||||
end
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
# typed: strict
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "autobump_constants"
|
||||
require "cache_store"
|
||||
require "did_you_mean"
|
||||
require "formula_support"
|
||||
@ -4202,10 +4203,14 @@ class Formula
|
||||
# Method that excludes the formula from the autobump list.
|
||||
#
|
||||
# @api public
|
||||
sig { params(because: String).returns(T.untyped) }
|
||||
sig { params(because: T.any(String, Symbol)).returns(T.untyped) }
|
||||
def no_autobump!(because:)
|
||||
if because.is_a?(Symbol) && !NO_AUTOBUMP_REASONS_LIST.key?(because)
|
||||
raise ArgumentError, "'because' argument should use valid symbol or a string!"
|
||||
end
|
||||
|
||||
@no_autobump_defined = T.let(true, T.nilable(T::Boolean))
|
||||
@no_autobump_message = T.let(because, T.nilable(String))
|
||||
@no_autobump_message = T.let(because.to_s, T.nilable(String))
|
||||
@autobump = T.let(false, T.nilable(T::Boolean))
|
||||
end
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user