bump-cask-pr: cleanup handling of multiple hashes
This commit is contained in:
parent
f765382cb6
commit
092095a249
@ -121,8 +121,8 @@ module Homebrew
|
|||||||
if new_version.present?
|
if new_version.present?
|
||||||
if new_version.latest?
|
if new_version.latest?
|
||||||
opoo "Ignoring specified `--sha256=` argument." if new_hash.present?
|
opoo "Ignoring specified `--sha256=` argument." if new_hash.present?
|
||||||
new_hash = :no_check
|
replacement_pairs << [old_hash, ":no_check"]
|
||||||
elsif new_hash.nil? || cask.languages.present?
|
elsif old_hash != :no_check && (new_hash.nil? || cask.languages.present?)
|
||||||
tmp_contents = Utils::Inreplace.inreplace_pairs(cask.sourcefile_path,
|
tmp_contents = Utils::Inreplace.inreplace_pairs(cask.sourcefile_path,
|
||||||
replacement_pairs.uniq.compact,
|
replacement_pairs.uniq.compact,
|
||||||
read_only_run: true,
|
read_only_run: true,
|
||||||
@ -131,43 +131,34 @@ module Homebrew
|
|||||||
tmp_cask = Cask::CaskLoader.load(tmp_contents)
|
tmp_cask = Cask::CaskLoader.load(tmp_contents)
|
||||||
tmp_config = tmp_cask.config
|
tmp_config = tmp_cask.config
|
||||||
|
|
||||||
new_hash = fetch_cask(tmp_contents)[1] if old_hash != :no_check && new_hash.nil?
|
[:arm, :intel].each do |arch|
|
||||||
|
Homebrew::SimulateSystem.arch = arch
|
||||||
|
|
||||||
cask.languages.each do |language|
|
languages = cask.languages
|
||||||
lang_config = tmp_config.merge(Cask::Config.new(explicit: { languages: [language] }))
|
languages = [nil] if languages.empty?
|
||||||
replacement_pairs << fetch_cask(tmp_contents, config: lang_config)
|
languages.each do |language|
|
||||||
end
|
new_hash_config = if language.blank?
|
||||||
|
tmp_config
|
||||||
|
else
|
||||||
|
tmp_config.merge(Cask::Config.new(explicit: { languages: [language] }))
|
||||||
|
end
|
||||||
|
|
||||||
# TODO: remove the `Hardware::CPU.intel?` substitution once no casks use the conditional
|
new_hash_cask = Cask::CaskLoader.load(tmp_contents)
|
||||||
other_intel = !Hardware::CPU.intel?
|
new_hash_cask.config = new_hash_config
|
||||||
Homebrew::SimulateSystem.arch = other_intel ? :intel : :arm
|
old_hash = new_hash_cask.sha256.to_s
|
||||||
other_contents = tmp_contents.gsub("Hardware::CPU.intel?", other_intel.to_s)
|
|
||||||
other_cask = Cask::CaskLoader.load(other_contents)
|
|
||||||
|
|
||||||
if other_cask.url.to_s != tmp_cask.url.to_s
|
cask_download = Cask::Download.new(new_hash_cask, quarantine: true)
|
||||||
if other_cask.sha256 != :no_check && other_cask.language.blank?
|
download = cask_download.fetch(verify_download_integrity: false)
|
||||||
replacement_pairs << fetch_cask(other_contents)
|
Utils::Tar.validate_file(download)
|
||||||
|
|
||||||
|
replacement_pairs << [new_hash_cask.sha256.to_s, download.sha256]
|
||||||
end
|
end
|
||||||
|
|
||||||
other_cask.languages.each do |language|
|
Homebrew::SimulateSystem.clear
|
||||||
lang_config = other_cask.config.merge(Cask::Config.new(explicit: { languages: [language] }))
|
|
||||||
replacement_pairs << fetch_cask(other_contents, config: lang_config)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
Homebrew::SimulateSystem.clear
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
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)}[\"']"
|
|
||||||
|
|
||||||
replacement_pairs << [
|
|
||||||
/#{hash_regex}/m,
|
|
||||||
((new_hash == :no_check) ? ":no_check" : "\"#{new_hash}\"").to_s,
|
|
||||||
]
|
|
||||||
end
|
|
||||||
|
|
||||||
Utils::Inreplace.inreplace_pairs(cask.sourcefile_path,
|
Utils::Inreplace.inreplace_pairs(cask.sourcefile_path,
|
||||||
replacement_pairs.uniq.compact,
|
replacement_pairs.uniq.compact,
|
||||||
read_only_run: args.dry_run?,
|
read_only_run: args.dry_run?,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user