Merge pull request #13718 from Rylan12/fix-bump-cask-pr

Fix multi-arch cask `sha256` updates
This commit is contained in:
Rylan Polster 2022-08-18 15:44:01 -04:00 committed by GitHub
commit c84453b152
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -138,13 +138,13 @@ module Homebrew
replacement_pairs << fetch_cask(tmp_contents, config: lang_config) replacement_pairs << fetch_cask(tmp_contents, config: lang_config)
end end
# TODO: Use SimulateSystem once all casks use on_system blocks # TODO: remove the `Hardware::CPU.intel?` substitution once no casks use the conditional
if tmp_contents.include?("Hardware::CPU.intel?")
other_intel = !Hardware::CPU.intel? other_intel = !Hardware::CPU.intel?
Homebrew::SimulateSystem.arch = other_intel ? :intel : :arm Homebrew::SimulateSystem.arch = other_intel ? :intel : :arm
other_contents = tmp_contents.gsub("Hardware::CPU.intel?", other_intel.to_s) other_contents = tmp_contents.gsub("Hardware::CPU.intel?", other_intel.to_s)
other_cask = Cask::CaskLoader.load(other_contents) other_cask = Cask::CaskLoader.load(other_contents)
if other_cask.url.to_s != tmp_cask.url.to_s
if other_cask.sha256 != :no_check && other_cask.language.blank? if other_cask.sha256 != :no_check && other_cask.language.blank?
replacement_pairs << fetch_cask(other_contents) replacement_pairs << fetch_cask(other_contents)
end end
@ -153,18 +153,18 @@ module Homebrew
lang_config = other_cask.config.merge(Cask::Config.new(explicit: { languages: [language] })) lang_config = other_cask.config.merge(Cask::Config.new(explicit: { languages: [language] }))
replacement_pairs << fetch_cask(other_contents, config: lang_config) replacement_pairs << fetch_cask(other_contents, config: lang_config)
end end
end
Homebrew::SimulateSystem.clear Homebrew::SimulateSystem.clear
end end
end end
end
if new_hash.present? && cask.language.blank? # avoid repeated replacement for multilanguage cask if new_hash.present? && cask.language.blank? # avoid repeated replacement for multilanguage cask
hash_regex = (old_hash == :no_check) ? ":no_check" : "[\"']#{Regexp.escape(old_hash.to_s)}[\"']" hash_regex = (old_hash == :no_check) ? ":no_check" : "[\"']#{Regexp.escape(old_hash.to_s)}[\"']"
replacement_pairs << [ replacement_pairs << [
/sha256\s+#{hash_regex}/m, /#{hash_regex}/m,
"sha256 #{(new_hash == :no_check) ? ":no_check" : "\"#{new_hash}\""}", ((new_hash == :no_check) ? ":no_check" : "\"#{new_hash}\"").to_s,
] ]
end end