mirror of
https://github.com/Homebrew/brew.git
synced 2025-07-15 19:56:59 +08:00
Merge pull request #18214 from Homebrew/audit-result-keyword
This commit is contained in:
commit
cd5cf4e2c8
@ -2866,11 +2866,18 @@ class Formula
|
|||||||
paths: T.any(T::Enumerable[T.any(String, Pathname)], String, Pathname),
|
paths: T.any(T::Enumerable[T.any(String, Pathname)], String, Pathname),
|
||||||
before: T.nilable(T.any(Pathname, Regexp, String)),
|
before: T.nilable(T.any(Pathname, Regexp, String)),
|
||||||
after: T.nilable(T.any(Pathname, String, Symbol)),
|
after: T.nilable(T.any(Pathname, String, Symbol)),
|
||||||
|
old_audit_result: T.nilable(T::Boolean),
|
||||||
audit_result: T::Boolean,
|
audit_result: T::Boolean,
|
||||||
block: T.nilable(T.proc.params(s: StringInreplaceExtension).void),
|
block: T.nilable(T.proc.params(s: StringInreplaceExtension).void),
|
||||||
).void
|
).void
|
||||||
}
|
}
|
||||||
def inreplace(paths, before = nil, after = nil, audit_result = true, &block) # rubocop:disable Style/OptionalBooleanParameter
|
def inreplace(paths, before = nil, after = nil, old_audit_result = nil, audit_result: true, &block)
|
||||||
|
# NOTE: must check for `#nil?` and not `#blank?`, or else `old_audit_result = false` will not call `odeprecated`.
|
||||||
|
unless old_audit_result.nil?
|
||||||
|
# odeprecated "inreplace(paths, before, after, #{old_audit_result})",
|
||||||
|
# "inreplace(paths, before, after, audit_result: #{old_audit_result})"
|
||||||
|
audit_result = old_audit_result
|
||||||
|
end
|
||||||
Utils::Inreplace.inreplace(paths, before, after, audit_result:, &block)
|
Utils::Inreplace.inreplace(paths, before, after, audit_result:, &block)
|
||||||
rescue Utils::Inreplace::Error => e
|
rescue Utils::Inreplace::Error => e
|
||||||
onoe e.to_s
|
onoe e.to_s
|
||||||
|
@ -29,10 +29,20 @@ class StringInreplaceExtension
|
|||||||
#
|
#
|
||||||
# @api public
|
# @api public
|
||||||
sig {
|
sig {
|
||||||
params(before: T.any(Pathname, Regexp, String), after: T.any(Pathname, String), audit_result: T::Boolean)
|
params(
|
||||||
.returns(T.nilable(String))
|
before: T.any(Pathname, Regexp, String),
|
||||||
|
after: T.any(Pathname, String),
|
||||||
|
old_audit_result: T.nilable(T::Boolean),
|
||||||
|
audit_result: T::Boolean,
|
||||||
|
).returns(T.nilable(String))
|
||||||
}
|
}
|
||||||
def gsub!(before, after, audit_result = true) # rubocop:disable Style/OptionalBooleanParameter
|
def gsub!(before, after, old_audit_result = nil, audit_result: true)
|
||||||
|
# NOTE: must check for `#nil?` and not `#blank?`, or else `old_audit_result = false` will not call `odeprecated`.
|
||||||
|
unless old_audit_result.nil?
|
||||||
|
# odeprecated "gsub!(before, after, #{old_audit_result})",
|
||||||
|
# "gsub!(before, after, audit_result: #{old_audit_result})"
|
||||||
|
audit_result = old_audit_result
|
||||||
|
end
|
||||||
before = before.to_s if before.is_a?(Pathname)
|
before = before.to_s if before.is_a?(Pathname)
|
||||||
result = inreplace_string.gsub!(before, after.to_s)
|
result = inreplace_string.gsub!(before, after.to_s)
|
||||||
errors << "expected replacement of #{before.inspect} with #{after.inspect}" if audit_result && result.nil?
|
errors << "expected replacement of #{before.inspect} with #{after.inspect}" if audit_result && result.nil?
|
||||||
|
Loading…
x
Reference in New Issue
Block a user