Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use native Hash#except, remove ActiveSupport 🐵-patch #16320

Merged
merged 6 commits into from
Dec 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,7 @@
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/file/atomic.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/hash/deep_merge.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/hash/deep_transform_values.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/hash/except.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/hash/keys.rb
!**/vendor/bundle/ruby/*/gems/activesupport-*/lib/active_support/core_ext/hash/slice.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/string/exclude.rb
Expand Down
4 changes: 1 addition & 3 deletions Library/Homebrew/dev-cmd/update-maintainers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
require "utils/github"
require "manpages"

require "active_support/core_ext/hash/slice"

module Homebrew
module_function

Expand Down Expand Up @@ -39,7 +37,7 @@

sentences = {}
members.each do |group, hash|
hash.slice!(*public_members)
hash.replace(hash.slice(*public_members))

Check warning on line 40 in Library/Homebrew/dev-cmd/update-maintainers.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/update-maintainers.rb#L40

Added line #L40 was not covered by tests
hash.each { |login, name| hash[login] = "[#{name}](https://github.com/#{login})" }
sentences[group] = hash.values.sort.to_sentence
end
Expand Down
1 change: 0 additions & 1 deletion Library/Homebrew/global.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
require "active_support/core_ext/enumerable"
require "active_support/core_ext/file/atomic"
require "active_support/core_ext/hash/deep_merge"
require "active_support/core_ext/hash/except"
require "active_support/core_ext/hash/keys"
require "active_support/core_ext/string/exclude"
require "active_support/core_ext/string/filters"
Expand Down
55 changes: 33 additions & 22 deletions Library/Homebrew/livecheck/livecheck.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# typed: true
# typed: strict
# frozen_string_literal: true

require "livecheck/constants"
Expand All @@ -18,18 +18,18 @@
module Livecheck
module_function

GITEA_INSTANCES = %w[
GITEA_INSTANCES = T.let(%w[
codeberg.org
gitea.com
opendev.org
tildegit.org
].freeze
].freeze, T::Array[String])

GOGS_INSTANCES = %w[
GOGS_INSTANCES = T.let(%w[
lolg.it
].freeze
].freeze, T::Array[String])

STRATEGY_SYMBOLS_TO_SKIP_PREPROCESS_URL = [
STRATEGY_SYMBOLS_TO_SKIP_PREPROCESS_URL = T.let([
:extract_plist,
:github_latest,
:header_match,
Expand All @@ -38,9 +38,9 @@
:sparkle,
:xml,
:yaml,
].freeze
].freeze, T::Array[Symbol])

UNSTABLE_VERSION_KEYWORDS = %w[
UNSTABLE_VERSION_KEYWORDS = T.let(%w[
alpha
beta
bpo
Expand All @@ -49,21 +49,21 @@
prerelease
preview
rc
].freeze
].freeze, T::Array[String])

sig { returns(T::Hash[Class, String]) }
def livecheck_strategy_names
return @livecheck_strategy_names if defined?(@livecheck_strategy_names)
return T.must(@livecheck_strategy_names) if defined?(@livecheck_strategy_names)

# Cache demodulized strategy names, to avoid repeating this work
@livecheck_strategy_names = {}
@livecheck_strategy_names = T.let({}, T.nilable(T::Hash[Class, String]))
Strategy.constants.sort.each do |const_symbol|
constant = Strategy.const_get(const_symbol)
next unless constant.is_a?(Class)

@livecheck_strategy_names[constant] = Utils.demodulize(T.must(constant.name))
T.must(@livecheck_strategy_names)[constant] = Utils.demodulize(T.must(constant.name))
end
@livecheck_strategy_names.freeze
T.must(@livecheck_strategy_names).freeze
end

# Uses `formulae_and_casks_to_check` to identify taps in use other than
Expand All @@ -83,7 +83,7 @@

other_taps.each_value do |tap|
tap_strategy_path = "#{tap.path}/livecheck/strategy"
Dir["#{tap_strategy_path}/*.rb"].sort.each(&method(:require)) if Dir.exist?(tap_strategy_path)
Dir["#{tap_strategy_path}/*.rb"].sort.each { require(_1) } if Dir.exist?(tap_strategy_path)
end
end

Expand Down Expand Up @@ -321,7 +321,12 @@
latest_info = status_hash(formula_or_cask, "error", [no_versions_msg], full_name: use_full_name,
verbose: verbose)
if check_for_resources
resource_version_info.map! { |r| r.except!(:meta) } unless verbose
unless verbose
resource_version_info.map! do |info|
info.delete(:meta)
info

Check warning on line 327 in Library/Homebrew/livecheck/livecheck.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/livecheck/livecheck.rb#L326-L327

Added lines #L326 - L327 were not covered by tests
end
end
latest_info[:resources] = resource_version_info
end

Expand Down Expand Up @@ -368,8 +373,13 @@

if json
progress&.increment
info.except!(:meta) unless verbose
resource_version_info.map! { |r| r.except!(:meta) } if check_for_resources && !verbose
info.delete(:meta) unless verbose
if check_for_resources && !verbose
resource_version_info.map! do |info|
info.delete(:meta)
info

Check warning on line 380 in Library/Homebrew/livecheck/livecheck.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/livecheck/livecheck.rb#L379-L380

Added lines #L379 - L380 were not covered by tests
end
end
next info
end
puts if debug
Expand Down Expand Up @@ -446,7 +456,7 @@
messages: T.nilable(T::Array[String]),
full_name: T::Boolean,
verbose: T::Boolean,
).returns(Hash)
).returns(T::Hash[Symbol, T.untyped])
}
def status_hash(package_or_resource, status_str, messages = nil, full_name: false, verbose: false)
formula = package_or_resource if package_or_resource.is_a?(Formula)
Expand All @@ -473,7 +483,7 @@
end

# Formats and prints the livecheck result for a formula/cask/resource.
sig { params(info: Hash, verbose: T::Boolean, ambiguous_cask: T::Boolean).void }
sig { params(info: T::Hash[Symbol, T.untyped], verbose: T::Boolean, ambiguous_cask: T::Boolean).void }
def print_latest_version(info, verbose: false, ambiguous_cask: false)
package_or_resource_s = info[:resource].present? ? " " : ""
package_or_resource_s += "#{Tty.blue}#{info[:formula] || info[:cask] || info[:resource]}#{Tty.reset}"
Expand All @@ -496,7 +506,7 @@
end

# Prints the livecheck result for the resources of a given Formula.
sig { params(info: T::Array[Hash], verbose: T::Boolean).void }
sig { params(info: T::Array[T::Hash[Symbol, T.untyped]], verbose: T::Boolean).void }
def print_resources_info(info, verbose: false)
info.each do |r_info|
if r_info[:status] && r_info[:messages]
Expand Down Expand Up @@ -633,7 +643,7 @@
full_name: T::Boolean,
verbose: T::Boolean,
debug: T::Boolean,
).returns(T.nilable(Hash))
).returns(T.nilable(T::Hash[Symbol, T.untyped]))
}
def latest_version(
formula_or_cask,
Expand Down Expand Up @@ -834,6 +844,7 @@
end
nil
end

# Identifies the latest version of a resource and returns a Hash containing the
# version information. Returns nil if a latest version couldn't be found.
sig {
Expand All @@ -844,7 +855,7 @@
debug: T::Boolean,
quiet: T::Boolean,
verbose: T::Boolean,
).returns(Hash)
).returns(T::Hash[Symbol, T.untyped])
}
def resource_version(
resource,
Expand Down

This file was deleted.

This file was deleted.