mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-14 16:09:03 +08:00
formula/cask DSL: add no_autobump!
method
Signed-off-by: botantony <antonsm21@gmail.com>
This commit is contained in:
parent
0195d9a6d6
commit
1fcacdc2dc
@ -17,6 +17,7 @@ FORMULA_COMPONENT_PRECEDENCE_LIST = T.let([
|
|||||||
[{ name: :head, type: :method_call }],
|
[{ name: :head, type: :method_call }],
|
||||||
[{ name: :stable, type: :block_call }],
|
[{ name: :stable, type: :block_call }],
|
||||||
[{ name: :livecheck, type: :block_call }],
|
[{ name: :livecheck, type: :block_call }],
|
||||||
|
[{ name: :no_autobump!, type: :method_call }],
|
||||||
[{ name: :bottle, type: :block_call }],
|
[{ name: :bottle, type: :block_call }],
|
||||||
[{ name: :pour_bottle?, type: :block_call }],
|
[{ name: :pour_bottle?, type: :block_call }],
|
||||||
[{ name: :head, type: :block_call }],
|
[{ name: :head, type: :block_call }],
|
||||||
|
@ -371,6 +371,8 @@ module Cask
|
|||||||
"url" => url,
|
"url" => url,
|
||||||
"url_specs" => url_specs,
|
"url_specs" => url_specs,
|
||||||
"version" => version,
|
"version" => version,
|
||||||
|
"autobump" => autobump?,
|
||||||
|
"no_autobump_message" => no_autobump_message,
|
||||||
"installed" => installed_version,
|
"installed" => installed_version,
|
||||||
"installed_time" => install_time&.to_i,
|
"installed_time" => install_time&.to_i,
|
||||||
"bundle_version" => bundle_long_version,
|
"bundle_version" => bundle_long_version,
|
||||||
|
@ -102,6 +102,10 @@ module Cask
|
|||||||
:livecheck,
|
:livecheck,
|
||||||
:livecheck_defined?,
|
:livecheck_defined?,
|
||||||
:livecheckable?, # TODO: remove once `#livecheckable?` is removed
|
:livecheckable?, # TODO: remove once `#livecheckable?` is removed
|
||||||
|
:no_autobump!,
|
||||||
|
:autobump?,
|
||||||
|
:no_autobump_defined?,
|
||||||
|
:no_autobump_message,
|
||||||
:on_system_blocks_exist?,
|
:on_system_blocks_exist?,
|
||||||
:on_system_block_min_os,
|
:on_system_block_min_os,
|
||||||
:depends_on_set_in_block?,
|
:depends_on_set_in_block?,
|
||||||
@ -112,7 +116,7 @@ module Cask
|
|||||||
|
|
||||||
include OnSystem::MacOSAndLinux
|
include OnSystem::MacOSAndLinux
|
||||||
|
|
||||||
attr_reader :cask, :token, :artifacts, :deprecation_date, :deprecation_reason,
|
attr_reader :cask, :token, :no_autobump_message, :artifacts, :deprecation_date, :deprecation_reason,
|
||||||
:deprecation_replacement_cask, :deprecation_replacement_formula,
|
:deprecation_replacement_cask, :deprecation_replacement_formula,
|
||||||
:disable_date, :disable_reason, :disable_replacement_cask,
|
:disable_date, :disable_reason, :disable_replacement_cask,
|
||||||
:disable_replacement_formula, :on_system_block_min_os
|
:disable_replacement_formula, :on_system_block_min_os
|
||||||
@ -147,6 +151,8 @@ module Cask
|
|||||||
@livecheck = T.let(Livecheck.new(cask), Livecheck)
|
@livecheck = T.let(Livecheck.new(cask), Livecheck)
|
||||||
@livecheck_defined = T.let(false, T::Boolean)
|
@livecheck_defined = T.let(false, T::Boolean)
|
||||||
@name = T.let([], T::Array[String])
|
@name = T.let([], T::Array[String])
|
||||||
|
@autobump = T.let(true, T::Boolean)
|
||||||
|
@no_autobump_defined = T.let(false, T::Boolean)
|
||||||
@on_system_blocks_exist = T.let(false, T::Boolean)
|
@on_system_blocks_exist = T.let(false, T::Boolean)
|
||||||
@os = T.let(nil, T.nilable(String))
|
@os = T.let(nil, T.nilable(String))
|
||||||
@on_system_block_min_os = T.let(nil, T.nilable(MacOSVersion))
|
@on_system_block_min_os = T.let(nil, T.nilable(MacOSVersion))
|
||||||
@ -540,6 +546,26 @@ module Cask
|
|||||||
@livecheck_defined == true
|
@livecheck_defined == true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def no_autobump!(because:)
|
||||||
|
raise ArgumentError, "`because` argument must be a string!" unless because.is_a?(String)
|
||||||
|
|
||||||
|
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
|
||||||
|
@autobump = false
|
||||||
|
end
|
||||||
|
|
||||||
|
def autobump?
|
||||||
|
@autobump == true
|
||||||
|
end
|
||||||
|
|
||||||
|
def no_autobump_defined?
|
||||||
|
@no_autobump_defined == true
|
||||||
|
end
|
||||||
|
|
||||||
# Declare that a cask is no longer functional or supported.
|
# Declare that a cask is no longer functional or supported.
|
||||||
#
|
#
|
||||||
# NOTE: A warning will be shown when trying to install this cask.
|
# NOTE: A warning will be shown when trying to install this cask.
|
||||||
|
@ -213,6 +213,9 @@ class Formula
|
|||||||
sig { returns(T::Boolean) }
|
sig { returns(T::Boolean) }
|
||||||
attr_accessor :follow_installed_alias
|
attr_accessor :follow_installed_alias
|
||||||
|
|
||||||
|
sig { returns(T.nilable(String)) }
|
||||||
|
attr_reader :no_autobump_message
|
||||||
|
|
||||||
alias follow_installed_alias? follow_installed_alias
|
alias follow_installed_alias? follow_installed_alias
|
||||||
|
|
||||||
# Whether or not to force the use of a bottle.
|
# Whether or not to force the use of a bottle.
|
||||||
@ -242,6 +245,9 @@ class Formula
|
|||||||
@head = T.let(nil, T.nilable(SoftwareSpec))
|
@head = T.let(nil, T.nilable(SoftwareSpec))
|
||||||
@stable = T.let(nil, T.nilable(SoftwareSpec))
|
@stable = T.let(nil, T.nilable(SoftwareSpec))
|
||||||
|
|
||||||
|
@autobump = T.let(true, T::Boolean)
|
||||||
|
@no_autobump_message = T.let(nil, T.nilable(String))
|
||||||
|
|
||||||
@force_bottle = T.let(force_bottle, T::Boolean)
|
@force_bottle = T.let(force_bottle, T::Boolean)
|
||||||
|
|
||||||
@tap = T.let(tap, T.nilable(Tap))
|
@tap = T.let(tap, T.nilable(Tap))
|
||||||
@ -474,6 +480,14 @@ class Formula
|
|||||||
# @see .livecheckable?
|
# @see .livecheckable?
|
||||||
delegate livecheckable?: :"self.class"
|
delegate livecheckable?: :"self.class"
|
||||||
|
|
||||||
|
delegate no_autobump!: :"self.class"
|
||||||
|
|
||||||
|
delegate autobump?: :"self.class"
|
||||||
|
|
||||||
|
delegate no_autobump_defined?: :"self.class"
|
||||||
|
|
||||||
|
delegate no_autobump_message: :"self.class"
|
||||||
|
|
||||||
# Is a service specification defined for the software?
|
# Is a service specification defined for the software?
|
||||||
# @!method service?
|
# @!method service?
|
||||||
# @see .service?
|
# @see .service?
|
||||||
@ -2484,6 +2498,8 @@ class Formula
|
|||||||
"urls" => urls_hash,
|
"urls" => urls_hash,
|
||||||
"revision" => revision,
|
"revision" => revision,
|
||||||
"version_scheme" => version_scheme,
|
"version_scheme" => version_scheme,
|
||||||
|
"autobump" => autobump?,
|
||||||
|
"no_autobump_message" => no_autobump_message,
|
||||||
"bottle" => {},
|
"bottle" => {},
|
||||||
"pour_bottle_only_if" => self.class.pour_bottle_only_if&.to_s,
|
"pour_bottle_only_if" => self.class.pour_bottle_only_if&.to_s,
|
||||||
"keg_only" => keg_only?,
|
"keg_only" => keg_only?,
|
||||||
@ -4182,6 +4198,25 @@ class Formula
|
|||||||
@livecheck.instance_eval(&block)
|
@livecheck.instance_eval(&block)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Method that excludes the formula from the autobump list.
|
||||||
|
#
|
||||||
|
# @api public
|
||||||
|
sig { params(because: String).returns(T.untyped) }
|
||||||
|
def no_autobump!(because:)
|
||||||
|
@no_autobump_defined = T.let(true, T.nilable(T::Boolean))
|
||||||
|
@no_autobump_message = T.let(because, T.nilable(String))
|
||||||
|
@autobump = T.let(false, T.nilable(T::Boolean))
|
||||||
|
end
|
||||||
|
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
|
def autobump? = @autobump == true
|
||||||
|
|
||||||
|
sig { returns(T::Boolean) }
|
||||||
|
def no_autobump_defined? = @no_autobump_defined == true
|
||||||
|
|
||||||
|
sig { returns(T.nilable(String)) }
|
||||||
|
attr_reader :no_autobump_message
|
||||||
|
|
||||||
# Service can be used to define services.
|
# Service can be used to define services.
|
||||||
# This method evaluates the DSL specified in the service block of the
|
# This method evaluates the DSL specified in the service block of the
|
||||||
# {Formula} (if it exists) and sets the instance variables of a Service
|
# {Formula} (if it exists) and sets the instance variables of a Service
|
||||||
|
@ -291,6 +291,10 @@ module Formulary
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if (no_autobump_msg = json_formula["no_autobump_msg"])
|
||||||
|
no_autobump! because: no_autobump_msg
|
||||||
|
end
|
||||||
|
|
||||||
bottles_stable = json_formula["bottle"]["stable"].presence
|
bottles_stable = json_formula["bottle"]["stable"].presence
|
||||||
|
|
||||||
if bottles_stable
|
if bottles_stable
|
||||||
|
@ -30,6 +30,9 @@ class Cask::Cask
|
|||||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||||
def auto_updates(*args, &block); end
|
def auto_updates(*args, &block); end
|
||||||
|
|
||||||
|
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||||
|
def autobump?(*args, &block); end
|
||||||
|
|
||||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||||
def bash_completion(*args, &block); end
|
def bash_completion(*args, &block); end
|
||||||
|
|
||||||
@ -141,6 +144,9 @@ class Cask::Cask
|
|||||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||||
def name(*args, &block); end
|
def name(*args, &block); end
|
||||||
|
|
||||||
|
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||||
|
def no_autobump_msg(*args, &block); end
|
||||||
|
|
||||||
sig { params(args: T.untyped, block: T.untyped).returns(T.nilable(MacOSVersion)) }
|
sig { params(args: T.untyped, block: T.untyped).returns(T.nilable(MacOSVersion)) }
|
||||||
def on_system_block_min_os(*args, &block); end
|
def on_system_block_min_os(*args, &block); end
|
||||||
|
|
||||||
|
@ -6,6 +6,9 @@
|
|||||||
|
|
||||||
|
|
||||||
class Formula
|
class Formula
|
||||||
|
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||||
|
def autobump?(*args, &block); end
|
||||||
|
|
||||||
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
sig { params(args: T.untyped, block: T.untyped).returns(T.untyped) }
|
||||||
def allow_network_access!(*args, &block); end
|
def allow_network_access!(*args, &block); end
|
||||||
|
|
||||||
|
@ -155,6 +155,24 @@ RSpec.describe Cask::DSL, :cask do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe "no_autobump! stanze" do
|
||||||
|
it "returns true if no_autobump! is not set" do
|
||||||
|
expect(cask.autobump?).to eq(true)
|
||||||
|
end
|
||||||
|
|
||||||
|
context "when no_autobump! is set" do
|
||||||
|
let(:cask) do
|
||||||
|
Cask::Cask.new("checksum-cask") do
|
||||||
|
no_autobump! because: "some reason"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
it "returns false" do
|
||||||
|
expect(cask.autobump?).to eq(false)
|
||||||
|
expect(cask.no_autobump_message).to eq("some reason")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe "language stanza" do
|
describe "language stanza" do
|
||||||
context "when language is set explicitly" do
|
context "when language is set explicitly" do
|
||||||
subject(:cask) do
|
subject(:cask) do
|
||||||
|
@ -16,6 +16,8 @@
|
|||||||
"user_agent": ":fake"
|
"user_agent": ":fake"
|
||||||
},
|
},
|
||||||
"version": "1.2.3",
|
"version": "1.2.3",
|
||||||
|
"autobump": true,
|
||||||
|
"no_autobump_msg": null,
|
||||||
"installed": null,
|
"installed": null,
|
||||||
"installed_time": null,
|
"installed_time": null,
|
||||||
"bundle_version": null,
|
"bundle_version": null,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user