Merge pull request #10683 from SeekingMeaning/bump-cask-pr-cpu

bump-cask-pr: support separate downloads for Intel and ARM
This commit is contained in:
Seeker 2021-03-18 07:12:47 -07:00 committed by GitHub
commit 7cf8ef636d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -125,29 +125,21 @@ module Homebrew
tmp_config = cask.config
tmp_url = tmp_cask.url.to_s
if new_hash.nil? && old_hash != :no_check
resource_path = fetch_resource(cask, new_version, tmp_url)
Utils::Tar.validate_file(resource_path)
new_hash = resource_path.sha256
if old_hash != :no_check
new_hash = fetch_resource(cask, new_version, tmp_url) if new_hash.nil?
if tmp_contents.include?("Hardware::CPU.intel?")
other_intel = !Hardware::CPU.intel?
other_contents = tmp_contents.gsub("Hardware::CPU.intel?", other_intel.to_s)
replacement_pairs << fetch_cask(other_contents, new_version)
end
end
cask.languages.each do |language|
next if language == cask.language
lang_config = tmp_config.merge(Cask::Config.new(explicit: { languages: [language] }))
lang_cask = Cask::CaskLoader.load(tmp_contents)
lang_cask.config = lang_config
lang_url = lang_cask.url.to_s
lang_old_hash = lang_cask.sha256.to_s
resource_path = fetch_resource(cask, new_version, lang_url)
Utils::Tar.validate_file(resource_path)
lang_new_hash = resource_path.sha256
replacement_pairs << [
lang_old_hash,
lang_new_hash,
]
replacement_pairs << fetch_cask(tmp_contents, new_version, config: lang_config)
end
end
end
@ -186,12 +178,24 @@ module Homebrew
GitHub.create_bump_pr(pr_info, args: args)
end
def fetch_resource(cask, new_version, url, **specs)
def fetch_resource(cask, version, url, **specs)
resource = Resource.new
resource.url(url, specs)
resource.owner = Resource.new(cask.token)
resource.version = new_version
resource.fetch
resource.version = version
resource_path = resource.fetch
Utils::Tar.validate_file(resource_path)
resource_path.sha256
end
def fetch_cask(contents, version, config: nil)
cask = Cask::CaskLoader.load(contents)
cask.config = config if config.present?
url = cask.url.to_s
old_hash = cask.sha256.to_s
new_hash = fetch_resource(cask, version, url)
[old_hash, new_hash]
end
def check_open_pull_requests(cask, args:)