dev-cmd/bump-formula-pr: fix reference
This commit is contained in:
parent
c5a3879fdb
commit
2b132c0802
@ -88,7 +88,7 @@ module Homebrew
|
|||||||
conflicts "--no-audit", "--online"
|
conflicts "--no-audit", "--online"
|
||||||
conflicts "--url", "--tag"
|
conflicts "--url", "--tag"
|
||||||
|
|
||||||
named_args :named_formula, max: 1, without_api: true
|
named_args :formula, max: 1, without_api: true
|
||||||
end
|
end
|
||||||
|
|
||||||
sig { override.void }
|
sig { override.void }
|
||||||
@ -104,17 +104,17 @@ module Homebrew
|
|||||||
# Use the user's browser, too.
|
# Use the user's browser, too.
|
||||||
ENV["BROWSER"] = Homebrew::EnvConfig.browser
|
ENV["BROWSER"] = Homebrew::EnvConfig.browser
|
||||||
|
|
||||||
named_formula = args.named.to_formulae.first
|
formula = args.named.to_formulae.first
|
||||||
raise FormulaUnspecifiedError if named_formula.blank?
|
raise FormulaUnspecifiedError if formula.blank?
|
||||||
|
|
||||||
odie "This formula is disabled!" if named_formula.disabled?
|
odie "This formula is disabled!" if formula.disabled?
|
||||||
odie "This formula is deprecated and does not build!" if named_formula.deprecation_reason == :does_not_build
|
odie "This formula is deprecated and does not build!" if formula.deprecation_reason == :does_not_build
|
||||||
tap = named_formula.tap
|
tap = formula.tap
|
||||||
odie "This formula is not in a tap!" if tap.blank?
|
odie "This formula is not in a tap!" if tap.blank?
|
||||||
odie "This formula's tap is not a Git repository!" unless tap.git?
|
odie "This formula's tap is not a Git repository!" unless tap.git?
|
||||||
|
|
||||||
odie <<~EOS unless tap.allow_bump?(named_formula.name)
|
odie <<~EOS unless tap.allow_bump?(formula.name)
|
||||||
Whoops, the #{named_formula.name} formula has its version update
|
Whoops, the #{formula.name} formula has its version update
|
||||||
pull requests automatically opened by BrewTestBot every ~3 hours!
|
pull requests automatically opened by BrewTestBot every ~3 hours!
|
||||||
We'd still love your contributions, though, so try another one
|
We'd still love your contributions, though, so try another one
|
||||||
that's not in the autobump list:
|
that's not in the autobump list:
|
||||||
@ -123,8 +123,8 @@ module Homebrew
|
|||||||
|
|
||||||
odie "You have too many PRs open: close or merge some first!" if GitHub.too_many_open_prs?(tap)
|
odie "You have too many PRs open: close or merge some first!" if GitHub.too_many_open_prs?(tap)
|
||||||
|
|
||||||
named_formula_spec = named_formula.stable
|
formula_spec = formula.stable
|
||||||
odie "#{named_formula}: no stable specification found!" if named_formula_spec.blank?
|
odie "#{formula}: no stable specification found!" if formula_spec.blank?
|
||||||
|
|
||||||
# This will be run by `brew audit` later so run it first to not start
|
# This will be run by `brew audit` later so run it first to not start
|
||||||
# spamming during normal output.
|
# spamming during normal output.
|
||||||
@ -135,7 +135,7 @@ module Homebrew
|
|||||||
remote_branch = tap.git_repository.origin_branch_name
|
remote_branch = tap.git_repository.origin_branch_name
|
||||||
previous_branch = "-"
|
previous_branch = "-"
|
||||||
|
|
||||||
check_pull_requests(named_formula, tap_remote_repo, state: "open")
|
check_pull_requests(formula, tap_remote_repo, state: "open")
|
||||||
|
|
||||||
all_formulae = []
|
all_formulae = []
|
||||||
if args.bump_synced.present?
|
if args.bump_synced.present?
|
||||||
@ -149,44 +149,44 @@ module Homebrew
|
|||||||
return if all_formulae.empty?
|
return if all_formulae.empty?
|
||||||
|
|
||||||
commits = all_formulae.filter_map do |formula_name|
|
commits = all_formulae.filter_map do |formula_name|
|
||||||
formula = Formula[formula_name]
|
commit_formula = Formula[formula_name]
|
||||||
raise FormulaUnspecifiedError if formula.blank?
|
raise FormulaUnspecifiedError if commit_formula.blank?
|
||||||
|
|
||||||
formula_spec = formula.stable
|
commit_formula_spec = commit_formula.stable
|
||||||
odie "#{formula}: no stable specification found!" if formula_spec.blank?
|
odie "#{commit_formula}: no stable specification found!" if commit_formula_spec.blank?
|
||||||
|
|
||||||
formula_pr_message = ""
|
formula_pr_message = ""
|
||||||
|
|
||||||
new_url = args.url
|
new_url = args.url
|
||||||
new_version = args.version
|
new_version = args.version
|
||||||
check_new_version(formula, tap_remote_repo, version: new_version) if new_version.present?
|
check_new_version(commit_formula, tap_remote_repo, version: new_version) if new_version.present?
|
||||||
|
|
||||||
opoo "This formula has patches that may be resolved upstream." if formula.patchlist.present?
|
opoo "This formula has patches that may be resolved upstream." if commit_formula.patchlist.present?
|
||||||
if formula.resources.any? { |resource| !resource.name.start_with?("homebrew-") }
|
if commit_formula.resources.any? { |resource| !resource.name.start_with?("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
|
||||||
|
|
||||||
old_mirrors = formula_spec.mirrors
|
old_mirrors = commit_formula_spec.mirrors
|
||||||
new_mirrors ||= args.mirror
|
new_mirrors ||= args.mirror
|
||||||
if new_url.present? && (new_mirror = determine_mirror(new_url))
|
if new_url.present? && (new_mirror = determine_mirror(new_url))
|
||||||
new_mirrors ||= [new_mirror]
|
new_mirrors ||= [new_mirror]
|
||||||
check_for_mirrors(formula.name, old_mirrors, new_mirrors)
|
check_for_mirrors(commit_formula.name, old_mirrors, new_mirrors)
|
||||||
end
|
end
|
||||||
|
|
||||||
old_hash = formula_spec.checksum&.hexdigest
|
old_hash = commit_formula_spec.checksum&.hexdigest
|
||||||
new_hash = args.sha256
|
new_hash = args.sha256
|
||||||
new_tag = args.tag
|
new_tag = args.tag
|
||||||
new_revision = args.revision
|
new_revision = args.revision
|
||||||
old_url = T.must(formula_spec.url)
|
old_url = T.must(commit_formula_spec.url)
|
||||||
old_tag = formula_spec.specs[:tag]
|
old_tag = commit_formula_spec.specs[:tag]
|
||||||
old_formula_version = formula_version(formula)
|
old_formula_version = formula_version(commit_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_new_version(formula, tap_remote_repo, url: new_url) if new_version.blank?
|
check_new_version(commit_formula, tap_remote_repo, url: new_url) if new_version.blank?
|
||||||
true
|
true
|
||||||
elsif new_tag.present? && new_revision.present?
|
elsif new_tag.present? && new_revision.present?
|
||||||
check_new_version(formula, tap_remote_repo, url: old_url, tag: new_tag) if new_version.blank?
|
check_new_version(commit_formula, tap_remote_repo, url: old_url, tag: new_tag) if new_version.blank?
|
||||||
false
|
false
|
||||||
elsif old_hash.blank?
|
elsif old_hash.blank?
|
||||||
if new_tag.blank? && new_version.blank? && new_revision.blank?
|
if new_tag.blank? && new_version.blank? && new_revision.blank?
|
||||||
@ -201,17 +201,17 @@ module Homebrew
|
|||||||
and old tag are both #{new_tag}.
|
and old tag are both #{new_tag}.
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
check_new_version(formula, tap_remote_repo, url: old_url, tag: new_tag) if new_version.blank?
|
check_new_version(commit_formula, tap_remote_repo, url: old_url, tag: new_tag) if new_version.blank?
|
||||||
resource_path, forced_version = fetch_resource_and_forced_version(formula, new_version, old_url,
|
resource_path, forced_version = fetch_resource_and_forced_version(commit_formula, new_version, old_url,
|
||||||
tag: new_tag)
|
tag: new_tag)
|
||||||
new_revision = Utils.popen_read("git", "-C", resource_path.to_s, "rev-parse", "-q", "--verify", "HEAD")
|
new_revision = Utils.popen_read("git", "-C", resource_path.to_s, "rev-parse", "-q", "--verify", "HEAD")
|
||||||
new_revision = new_revision.strip
|
new_revision = new_revision.strip
|
||||||
elsif new_revision.blank?
|
elsif new_revision.blank?
|
||||||
odie "#{formula}: the current URL requires specifying a `--revision=` argument."
|
odie "#{commit_formula}: the current URL requires specifying a `--revision=` argument."
|
||||||
end
|
end
|
||||||
false
|
false
|
||||||
elsif new_url.blank? && new_version.blank?
|
elsif new_url.blank? && new_version.blank?
|
||||||
raise UsageError, "#{formula}: no `--url` or `--version` argument specified!"
|
raise UsageError, "#{commit_formula}: no `--url` or `--version` argument specified!"
|
||||||
else
|
else
|
||||||
next unless new_version.present?
|
next unless new_version.present?
|
||||||
|
|
||||||
@ -231,21 +231,21 @@ module Homebrew
|
|||||||
#{new_url}
|
#{new_url}
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
check_new_version(formula, tap_remote_repo, url: new_url) if new_version.blank?
|
check_new_version(commit_formula, tap_remote_repo, url: new_url) if new_version.blank?
|
||||||
resource_path, forced_version = fetch_resource_and_forced_version(formula, new_version, new_url)
|
resource_path, forced_version = fetch_resource_and_forced_version(commit_formula, new_version, new_url)
|
||||||
Utils::Tar.validate_file(resource_path)
|
Utils::Tar.validate_file(resource_path)
|
||||||
new_hash = resource_path.sha256
|
new_hash = resource_path.sha256
|
||||||
end
|
end
|
||||||
|
|
||||||
replacement_pairs = []
|
replacement_pairs = []
|
||||||
if formula.revision.nonzero?
|
if commit_formula.revision.nonzero?
|
||||||
replacement_pairs << [
|
replacement_pairs << [
|
||||||
/^ revision \d+\n(\n( head "))?/m,
|
/^ revision \d+\n(\n( head "))?/m,
|
||||||
"\\2",
|
"\\2",
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
replacement_pairs += formula_spec.mirrors.map do |mirror|
|
replacement_pairs += commit_formula_spec.mirrors.map do |mirror|
|
||||||
[
|
[
|
||||||
/ +mirror "#{Regexp.escape(mirror)}"\n/m,
|
/ +mirror "#{Regexp.escape(mirror)}"\n/m,
|
||||||
"",
|
"",
|
||||||
@ -255,7 +255,7 @@ module Homebrew
|
|||||||
replacement_pairs += if new_url_hash.present?
|
replacement_pairs += if new_url_hash.present?
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
/#{Regexp.escape(T.must(formula_spec.url))}/,
|
/#{Regexp.escape(T.must(commit_formula_spec.url))}/,
|
||||||
new_url,
|
new_url,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
@ -266,35 +266,35 @@ module Homebrew
|
|||||||
elsif new_tag.present?
|
elsif new_tag.present?
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
/tag:(\s+")#{formula_spec.specs[:tag]}(?=")/,
|
/tag:(\s+")#{commit_formula_spec.specs[:tag]}(?=")/,
|
||||||
"tag:\\1#{new_tag}\\2",
|
"tag:\\1#{new_tag}\\2",
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
formula_spec.specs[:revision],
|
commit_formula_spec.specs[:revision],
|
||||||
new_revision,
|
new_revision,
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
elsif new_url.present?
|
elsif new_url.present?
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
/#{Regexp.escape(T.must(formula_spec.url))}/,
|
/#{Regexp.escape(T.must(commit_formula_spec.url))}/,
|
||||||
new_url,
|
new_url,
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
formula_spec.specs[:revision],
|
commit_formula_spec.specs[:revision],
|
||||||
new_revision,
|
new_revision,
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
else
|
else
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
formula_spec.specs[:revision],
|
commit_formula_spec.specs[:revision],
|
||||||
new_revision,
|
new_revision,
|
||||||
],
|
],
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
|
|
||||||
old_contents = formula.path.read
|
old_contents = commit_formula.path.read
|
||||||
|
|
||||||
if new_mirrors.present? && new_url.present?
|
if new_mirrors.present? && new_url.present?
|
||||||
replacement_pairs << [
|
replacement_pairs << [
|
||||||
@ -331,28 +331,28 @@ module Homebrew
|
|||||||
"",
|
"",
|
||||||
]
|
]
|
||||||
end
|
end
|
||||||
new_contents = Utils::Inreplace.inreplace_pairs(formula.path,
|
new_contents = Utils::Inreplace.inreplace_pairs(commit_formula.path,
|
||||||
replacement_pairs.uniq.compact,
|
replacement_pairs.uniq.compact,
|
||||||
read_only_run: args.dry_run?,
|
read_only_run: args.dry_run?,
|
||||||
silent: args.quiet?)
|
silent: args.quiet?)
|
||||||
|
|
||||||
new_formula_version = formula_version(formula, new_contents)
|
new_formula_version = formula_version(commit_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?
|
commit_formula.path.atomic_write(old_contents) unless args.dry_run?
|
||||||
odie <<~EOS
|
odie <<~EOS
|
||||||
You need to bump this formula manually since changing the version
|
You need to bump this formula manually since changing the version
|
||||||
from #{old_formula_version} to #{new_formula_version} would be a downgrade.
|
from #{old_formula_version} to #{new_formula_version} would be a downgrade.
|
||||||
EOS
|
EOS
|
||||||
elsif new_formula_version == old_formula_version
|
elsif new_formula_version == old_formula_version
|
||||||
formula.path.atomic_write(old_contents) unless args.dry_run?
|
commit_formula.path.atomic_write(old_contents) unless args.dry_run?
|
||||||
odie <<~EOS
|
odie <<~EOS
|
||||||
You need to bump this formula manually since the new version
|
You need to bump this formula manually since the new version
|
||||||
and old version are both #{new_formula_version}.
|
and old version are both #{new_formula_version}.
|
||||||
EOS
|
EOS
|
||||||
end
|
end
|
||||||
|
|
||||||
alias_rename = alias_update_pair(formula, new_formula_version)
|
alias_rename = alias_update_pair(commit_formula, new_formula_version)
|
||||||
if alias_rename.present?
|
if alias_rename.present?
|
||||||
ohai "Renaming alias #{alias_rename.first} to #{alias_rename.last}"
|
ohai "Renaming alias #{alias_rename.first} to #{alias_rename.last}"
|
||||||
alias_rename.map! { |a| tap.alias_dir/a }
|
alias_rename.map! { |a| tap.alias_dir/a }
|
||||||
@ -368,11 +368,11 @@ module Homebrew
|
|||||||
silent: args.quiet?,
|
silent: args.quiet?,
|
||||||
ignore_non_pypi_packages: true
|
ignore_non_pypi_packages: true
|
||||||
|
|
||||||
update_matching_version_resources! formula,
|
update_matching_version_resources! commit_formula,
|
||||||
version: new_formula_version.to_s
|
version: new_formula_version.to_s
|
||||||
end
|
end
|
||||||
|
|
||||||
if resources_checked.nil? && formula.resources.any? do |resource|
|
if resources_checked.nil? && commit_formula.resources.any? do |resource|
|
||||||
resource.livecheck.formula != :parent && !resource.name.start_with?("homebrew-")
|
resource.livecheck.formula != :parent && !resource.name.start_with?("homebrew-")
|
||||||
end
|
end
|
||||||
formula_pr_message += <<~EOS
|
formula_pr_message += <<~EOS
|
||||||
@ -405,12 +405,12 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
{
|
{
|
||||||
sourcefile_path: formula.path,
|
sourcefile_path: commit_formula.path,
|
||||||
old_contents:,
|
old_contents:,
|
||||||
commit_message: "#{formula.name} #{args.version}",
|
commit_message: "#{commit_formula.name} #{args.version}",
|
||||||
additional_files: alias_rename,
|
additional_files: alias_rename,
|
||||||
formula_pr_message:,
|
formula_pr_message:,
|
||||||
formula_name: formula.name,
|
formula_name: commit_formula.name,
|
||||||
new_version: new_formula_version,
|
new_version: new_formula_version,
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
@ -438,7 +438,7 @@ module Homebrew
|
|||||||
|
|
||||||
new_formula_version = T.must(commits.first)[:new_version]
|
new_formula_version = T.must(commits.first)[:new_version]
|
||||||
pr_title = if args.bump_synced.nil?
|
pr_title = if args.bump_synced.nil?
|
||||||
"#{named_formula.name} #{new_formula_version}"
|
"#{formula.name} #{new_formula_version}"
|
||||||
else
|
else
|
||||||
"#{Array(args.bump_synced).join(" ")} #{new_formula_version}"
|
"#{Array(args.bump_synced).join(" ")} #{new_formula_version}"
|
||||||
end
|
end
|
||||||
@ -455,7 +455,7 @@ module Homebrew
|
|||||||
commits:,
|
commits:,
|
||||||
remote:,
|
remote:,
|
||||||
remote_branch:,
|
remote_branch:,
|
||||||
branch_name: "bump-#{named_formula.name}-#{new_formula_version}",
|
branch_name: "bump-#{formula.name}-#{new_formula_version}",
|
||||||
pr_title:,
|
pr_title:,
|
||||||
previous_branch:,
|
previous_branch:,
|
||||||
tap: tap,
|
tap: tap,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user