Skip to content

Commit

Permalink
Merge pull request #16184 from dduugg/rm-try
Browse files Browse the repository at this point in the history
Remove use of ActiveSupport try
  • Loading branch information
MikeMcQuaid authored Nov 6, 2023
2 parents d4bf3b0 + 00ba09d commit ff404fe
Show file tree
Hide file tree
Showing 9 changed files with 17 additions and 170 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/object/blank.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/object/deep_dup.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/object/duplicable.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/object/try.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/string/exclude.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/string/filters.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/string/indent.rb
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/cask/artifact/artifact.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def self.from_args(cask, *args)

raise CaskInvalidError.new(cask.token, "No source provided for #{english_name}.") if source.blank?

unless options.try(:key?, :target)
unless options&.key?(:target)
raise CaskInvalidError.new(cask.token, "#{english_name} '#{source}' requires a target.")
end

Expand Down
10 changes: 5 additions & 5 deletions Library/Homebrew/cask/installer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,12 @@ def cask_and_formula_dependencies

def missing_cask_and_formula_dependencies
cask_and_formula_dependencies.reject do |cask_or_formula|
installed = if cask_or_formula.respond_to?(:any_version_installed?)
cask_or_formula.any_version_installed?
else
cask_or_formula.try(:installed?)
case cask_or_formula
when Formula
cask_or_formula.any_version_installed? && cask_or_formula.optlinked?
when Cask
cask_or_formula.installed?
end
installed && (cask_or_formula.respond_to?(:optlinked?) ? cask_or_formula.optlinked? : true)
end
end

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/bump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ def livecheck_result(formula_or_cask)
def retrieve_pull_requests(formula_or_cask, name, state:, version: nil)
tap_remote_repo = formula_or_cask.tap&.remote_repo || formula_or_cask.tap&.full_name
pull_requests = GitHub.fetch_pull_requests(name, tap_remote_repo, state: state, version: version)
if pull_requests.try(:any?)
if pull_requests&.any?
pull_requests = pull_requests.map { |pr| "#{pr["title"]} (#{Formatter.url(pr["html_url"])})" }.join(", ")
end

Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/extend/ENV/shared.rb
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ def gcc_version_formula(name)
gcc_version_name = "gcc@#{version}"

gcc = Formulary.factory("gcc")
if gcc.try(:version_suffix) == version
if gcc.respond_to?(:version_suffix) && T.unsafe(gcc).version_suffix == version
gcc
else
Formulary.factory(gcc_version_name)
Expand Down
9 changes: 7 additions & 2 deletions Library/Homebrew/formula.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2351,12 +2351,17 @@ def to_hash
hsh["requirements"] = merge_spec_dependables(requirements).map do |data|
req = data[:dependable]
req_name = req.name.dup
req_name.prepend("maximum_") if req.try(:comparator) == "<="
req_name.prepend("maximum_") if req.respond_to?(:comparator) && req.comparator == "<="
req_version = if req.respond_to?(:version)
req.version
elsif req.respond_to?(:arch)
req.arch
end
{
"name" => req_name,
"cask" => req.cask,
"download" => req.download,
"version" => req.try(:version) || req.try(:arch),
"version" => req_version,
"contexts" => req.tags,
"specs" => data[:specs],
}
Expand Down
1 change: 0 additions & 1 deletion Library/Homebrew/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
require "active_support/core_ext/hash/except"
require "active_support/core_ext/hash/keys"
require "active_support/core_ext/object/blank"
require "active_support/core_ext/object/try"
require "active_support/core_ext/string/exclude"
require "active_support/core_ext/string/filters"
require "active_support/core_ext/string/indent"
Expand Down
2 changes: 2 additions & 0 deletions Library/Homebrew/lazy_object.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# typed: true
# frozen_string_literal: true

require "delegate"

# An object which lazily evaluates its inner block only once a method is called on it.
#
# @api private
Expand Down

This file was deleted.

0 comments on commit ff404fe

Please sign in to comment.