bump-formula-pr: cleanup
This commit is contained in:
parent
d75e9c99b3
commit
8fdfbdfc0b
@ -140,6 +140,9 @@ module Homebrew
|
|||||||
|
|
||||||
odie "This formula is disabled!" if formula.disabled?
|
odie "This formula is disabled!" if formula.disabled?
|
||||||
|
|
||||||
|
formula_spec = formula.stable
|
||||||
|
odie "#{formula}: no stable specification found!" if formula_spec.blank?
|
||||||
|
|
||||||
tap_full_name, remote, remote_branch, previous_branch = use_correct_linux_tap(formula, args: args)
|
tap_full_name, remote, remote_branch, previous_branch = use_correct_linux_tap(formula, args: args)
|
||||||
check_open_pull_requests(formula, tap_full_name, args: args)
|
check_open_pull_requests(formula, tap_full_name, args: args)
|
||||||
|
|
||||||
@ -151,10 +154,6 @@ module Homebrew
|
|||||||
opoo "This formula has resources that may need to be updated."
|
opoo "This formula has resources that may need to be updated."
|
||||||
end
|
end
|
||||||
|
|
||||||
requested_spec = :stable
|
|
||||||
formula_spec = formula.stable
|
|
||||||
odie "#{formula}: no #{requested_spec} specification found!" if formula_spec.blank?
|
|
||||||
|
|
||||||
old_mirrors = formula_spec.mirrors
|
old_mirrors = formula_spec.mirrors
|
||||||
new_mirrors ||= args.mirror
|
new_mirrors ||= args.mirror
|
||||||
new_mirror ||= determine_mirror(new_url)
|
new_mirror ||= determine_mirror(new_url)
|
||||||
@ -168,13 +167,13 @@ module Homebrew
|
|||||||
new_revision = args.revision
|
new_revision = args.revision
|
||||||
old_url = formula_spec.url
|
old_url = formula_spec.url
|
||||||
old_tag = formula_spec.specs[:tag]
|
old_tag = formula_spec.specs[:tag]
|
||||||
old_formula_version = formula_version(formula, requested_spec)
|
old_formula_version = formula_version(formula)
|
||||||
old_version = old_formula_version.to_s
|
old_version = old_formula_version.to_s
|
||||||
forced_version = new_version.present?
|
forced_version = new_version.present?
|
||||||
new_url_hash = if new_url.present? && new_hash.present?
|
new_url_hash = if new_url.present? && new_hash.present?
|
||||||
check_closed_pull_requests(formula, tap_full_name, url: new_url, args: args) if new_version.blank?
|
check_closed_pull_requests(formula, tap_full_name, url: new_url, args: args) if new_version.blank?
|
||||||
true
|
true
|
||||||
elsif new_tag && new_revision
|
elsif new_tag.present? && new_revision.present?
|
||||||
check_closed_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag, args: args) if new_version.blank?
|
check_closed_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag, args: args) if new_version.blank?
|
||||||
false
|
false
|
||||||
elsif old_hash.blank?
|
elsif old_hash.blank?
|
||||||
@ -191,8 +190,7 @@ module Homebrew
|
|||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
if new_version.blank?
|
if new_version.blank?
|
||||||
check_closed_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag,
|
check_closed_pull_requests(formula, tap_full_name, url: old_url, tag: new_tag, args: args)
|
||||||
args: args)
|
|
||||||
end
|
end
|
||||||
resource_path, forced_version = fetch_resource(formula, new_version, old_url, tag: new_tag)
|
resource_path, forced_version = fetch_resource(formula, new_version, old_url, tag: new_tag)
|
||||||
new_revision = Utils.popen_read("git -C \"#{resource_path}\" rev-parse -q --verify HEAD")
|
new_revision = Utils.popen_read("git -C \"#{resource_path}\" rev-parse -q --verify HEAD")
|
||||||
@ -227,7 +225,7 @@ args: args)
|
|||||||
end
|
end
|
||||||
|
|
||||||
replacement_pairs = []
|
replacement_pairs = []
|
||||||
if requested_spec == :stable && formula.revision.nonzero?
|
if formula.revision.nonzero?
|
||||||
replacement_pairs << [
|
replacement_pairs << [
|
||||||
/^ revision \d+\n(\n( head "))?/m,
|
/^ revision \d+\n(\n( head "))?/m,
|
||||||
"\\2",
|
"\\2",
|
||||||
@ -283,7 +281,7 @@ args: args)
|
|||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
old_contents = File.read(formula.path) unless args.dry_run?
|
old_contents = formula.path.read
|
||||||
|
|
||||||
if new_mirrors.present?
|
if new_mirrors.present?
|
||||||
replacement_pairs << [
|
replacement_pairs << [
|
||||||
@ -295,8 +293,7 @@ args: args)
|
|||||||
# When bumping a linux-only formula, one needs to also delete the
|
# When bumping a linux-only formula, one needs to also delete the
|
||||||
# sha256 linux bottle line if it exists. That's because of running
|
# sha256 linux bottle line if it exists. That's because of running
|
||||||
# test-bot with --keep-old option in linuxbrew-core.
|
# test-bot with --keep-old option in linuxbrew-core.
|
||||||
formula_contents = formula.path.read
|
if old_contents.include?("depends_on :linux") && old_contents.include?("=> :x86_64_linux")
|
||||||
if formula_contents.include?("depends_on :linux") && formula_contents.include?("=> :x86_64_linux")
|
|
||||||
replacement_pairs << [
|
replacement_pairs << [
|
||||||
/^ sha256 ".+" => :x86_64_linux\n/m,
|
/^ sha256 ".+" => :x86_64_linux\n/m,
|
||||||
"\\2",
|
"\\2",
|
||||||
@ -304,7 +301,7 @@ args: args)
|
|||||||
end
|
end
|
||||||
|
|
||||||
if forced_version && new_version != "0"
|
if forced_version && new_version != "0"
|
||||||
replacement_pairs << if File.read(formula.path).include?("version \"#{old_formula_version}\"")
|
replacement_pairs << if old_contents.include?("version \"#{old_formula_version}\"")
|
||||||
[
|
[
|
||||||
old_formula_version.to_s,
|
old_formula_version.to_s,
|
||||||
new_version,
|
new_version,
|
||||||
@ -336,7 +333,7 @@ args: args)
|
|||||||
read_only_run: args.dry_run?,
|
read_only_run: args.dry_run?,
|
||||||
silent: args.quiet?)
|
silent: args.quiet?)
|
||||||
|
|
||||||
new_formula_version = formula_version(formula, requested_spec, new_contents)
|
new_formula_version = formula_version(formula, new_contents)
|
||||||
|
|
||||||
if new_formula_version < old_formula_version
|
if new_formula_version < old_formula_version
|
||||||
formula.path.atomic_write(old_contents) unless args.dry_run?
|
formula.path.atomic_write(old_contents) unless args.dry_run?
|
||||||
@ -446,7 +443,8 @@ args: args)
|
|||||||
[resource.fetch, forced_version]
|
[resource.fetch, forced_version]
|
||||||
end
|
end
|
||||||
|
|
||||||
def formula_version(formula, spec, contents = nil)
|
def formula_version(formula, contents = nil)
|
||||||
|
spec = :stable
|
||||||
name = formula.name
|
name = formula.name
|
||||||
path = formula.path
|
path = formula.path
|
||||||
if contents.present?
|
if contents.present?
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user