bump-formula-pr: update mirrors automatically

This commit is contained in:
Seeker 2020-09-07 10:22:08 -07:00
parent d0e1595fcf
commit ccde62082b

View File

@ -145,20 +145,12 @@ module Homebrew
formula_spec = formula.stable
odie "#{formula}: no #{requested_spec} specification found!" unless formula_spec
old_mirrors = formula_spec.mirrors
new_mirrors ||= args.mirror
new_mirror ||= determine_mirror(new_url)
new_mirrors ||= [new_mirror] unless new_mirror.nil?
if !new_mirrors && !formula_spec.mirrors.empty?
if args.force?
opoo "#{formula}: Removing all mirrors because a --mirror= argument was not specified."
else
odie <<~EOS
#{formula}: a --mirror= argument for updating the mirror URL was not specified.
Use --force to remove all mirrors.
EOS
end
end
check_for_mirrors(formula, old_mirrors, new_mirrors, args: args) if new_url
hash_type, old_hash = if (checksum = formula_spec.checksum)
[checksum.hash_type, checksum.hexdigest]
@ -196,7 +188,14 @@ module Homebrew
odie "#{formula}: no --url= or --version= argument specified!"
else
new_url ||= PyPI.update_pypi_url(old_url, new_version)
new_url ||= old_url.gsub(old_version, new_version)
unless new_url
new_url = old_url.gsub(old_version, new_version)
if !new_mirrors && !old_mirrors.empty?
new_mirrors = old_mirrors.map do |old_mirror|
old_mirror.gsub(old_version, new_version)
end
end
end
if new_url == old_url
odie <<~EOS
You need to bump this formula manually since the new URL
@ -389,6 +388,19 @@ module Homebrew
end
end
def check_for_mirrors(formula, old_mirrors, new_mirrors, args:)
return if new_mirrors || old_mirrors.empty?
if args.force?
opoo "#{formula}: Removing all mirrors because a --mirror= argument was not specified."
else
odie <<~EOS
#{formula}: a --mirror= argument for updating the mirror URL(s) was not specified.
Use --force to remove all mirrors.
EOS
end
end
def fetch_resource(formula, new_version, url, **specs)
resource = Resource.new
resource.url(url, specs)