bump-formula-pr: --mirror option

This commit is contained in:
ilovezfs 2016-09-04 11:28:02 -07:00
parent 743e9bbdaa
commit 19df03219b

View File

@ -100,6 +100,7 @@ module Homebrew
new_hash = ARGV.value(hash_type) new_hash = ARGV.value(hash_type)
new_tag = ARGV.value("tag") new_tag = ARGV.value("tag")
new_revision = ARGV.value("revision") new_revision = ARGV.value("revision")
new_mirror = ARGV.value("mirror")
new_url_hash = if new_url && new_hash new_url_hash = if new_url && new_hash
true true
elsif new_tag && new_revision elsif new_tag && new_revision
@ -132,6 +133,10 @@ module Homebrew
replacement_pairs << [/^ revision \d+\n(\n( head "))?/m, "\\2"] replacement_pairs << [/^ revision \d+\n(\n( head "))?/m, "\\2"]
end end
if requested_spec == :stable
replacement_pairs << [/(^ mirror .*\n)?/, ""]
end
replacement_pairs += if new_url_hash replacement_pairs += if new_url_hash
[ [
[formula_spec.url, new_url], [formula_spec.url, new_url],
@ -146,6 +151,10 @@ module Homebrew
backup_file = File.read(formula.path) unless ARGV.dry_run? backup_file = File.read(formula.path) unless ARGV.dry_run?
if new_mirror
replacement_pairs << [/^( +)(url \"#{new_url}\"\n)/m, "\\1\\2\\1mirror \"#{new_mirror}\"\n"]
end
new_contents = inreplace_pairs(formula.path, replacement_pairs) new_contents = inreplace_pairs(formula.path, replacement_pairs)
new_formula_version = formula_version(formula, requested_spec, new_contents) new_formula_version = formula_version(formula, requested_spec, new_contents)