Merge pull request #10251 from SeekingMeaning/bump-pr-match
bump-*-pr: check existing PRs for exact file match
This commit is contained in:
commit
b29c27b9a8
@ -67,6 +67,10 @@ module Homebrew
|
|||||||
ENV["BROWSER"] = Homebrew::EnvConfig.browser
|
ENV["BROWSER"] = Homebrew::EnvConfig.browser
|
||||||
|
|
||||||
cask = args.named.to_casks.first
|
cask = args.named.to_casks.first
|
||||||
|
|
||||||
|
odie "This cask is not in a tap!" if cask.tap.blank?
|
||||||
|
odie "This cask's tap is not a Git repository!" unless cask.tap.git?
|
||||||
|
|
||||||
new_version = args.version
|
new_version = args.version
|
||||||
new_version = :latest if ["latest", ":latest"].include?(new_version)
|
new_version = :latest if ["latest", ":latest"].include?(new_version)
|
||||||
new_version = Cask::DSL::Version.new(new_version) if new_version.present?
|
new_version = Cask::DSL::Version.new(new_version) if new_version.present?
|
||||||
@ -81,12 +85,7 @@ module Homebrew
|
|||||||
old_version = cask.version
|
old_version = cask.version
|
||||||
old_hash = cask.sha256
|
old_hash = cask.sha256
|
||||||
|
|
||||||
tap_full_name = cask.tap&.full_name
|
check_open_pull_requests(cask, args: args)
|
||||||
default_remote_branch = cask.tap.path.git_origin_branch if cask.tap
|
|
||||||
default_remote_branch ||= "master"
|
|
||||||
previous_branch = "-"
|
|
||||||
|
|
||||||
check_open_pull_requests(cask, tap_full_name, args: args)
|
|
||||||
|
|
||||||
old_contents = File.read(cask.sourcefile_path)
|
old_contents = File.read(cask.sourcefile_path)
|
||||||
|
|
||||||
@ -180,12 +179,9 @@ module Homebrew
|
|||||||
pr_info = {
|
pr_info = {
|
||||||
sourcefile_path: cask.sourcefile_path,
|
sourcefile_path: cask.sourcefile_path,
|
||||||
old_contents: old_contents,
|
old_contents: old_contents,
|
||||||
remote_branch: default_remote_branch,
|
|
||||||
branch_name: branch_name,
|
branch_name: branch_name,
|
||||||
commit_message: commit_message,
|
commit_message: commit_message,
|
||||||
previous_branch: previous_branch,
|
|
||||||
tap: cask.tap,
|
tap: cask.tap,
|
||||||
tap_full_name: tap_full_name,
|
|
||||||
pr_message: "Created with `brew bump-cask-pr`.",
|
pr_message: "Created with `brew bump-cask-pr`.",
|
||||||
}
|
}
|
||||||
GitHub.create_bump_pr(pr_info, args: args)
|
GitHub.create_bump_pr(pr_info, args: args)
|
||||||
@ -199,14 +195,11 @@ module Homebrew
|
|||||||
resource.fetch
|
resource.fetch
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_open_pull_requests(cask, tap_full_name, args:)
|
def check_open_pull_requests(cask, args:)
|
||||||
GitHub.check_for_duplicate_pull_requests(cask.token, tap_full_name, state: "open", args: args)
|
GitHub.check_for_duplicate_pull_requests(cask.token, cask.tap.full_name,
|
||||||
end
|
state: "open",
|
||||||
|
file: cask.sourcefile_path.relative_path_from(cask.tap.path).to_s,
|
||||||
def check_closed_pull_requests(cask, tap_full_name, version:, args:)
|
args: args)
|
||||||
# if we haven't already found open requests, try for an exact match across closed requests
|
|
||||||
pr_title = "Update #{cask.token} from #{cask.version} to #{version}"
|
|
||||||
GitHub.check_for_duplicate_pull_requests(pr_title, tap_full_name, state: "closed", args: args)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def run_cask_audit(cask, old_contents, args:)
|
def run_cask_audit(cask, old_contents, args:)
|
||||||
|
@ -84,9 +84,9 @@ module Homebrew
|
|||||||
end
|
end
|
||||||
|
|
||||||
def use_correct_linux_tap(formula, args:)
|
def use_correct_linux_tap(formula, args:)
|
||||||
default_origin_branch = formula.tap.path.git_origin_branch if formula.tap
|
default_origin_branch = formula.tap.path.git_origin_branch
|
||||||
|
|
||||||
return formula.tap&.full_name, "origin", default_origin_branch, "-" if !OS.linux? || !formula.tap.core_tap?
|
return formula.tap.full_name, "origin", default_origin_branch, "-" if !OS.linux? || !formula.tap.core_tap?
|
||||||
|
|
||||||
tap_full_name = formula.tap.full_name.gsub("linuxbrew", "homebrew")
|
tap_full_name = formula.tap.full_name.gsub("linuxbrew", "homebrew")
|
||||||
homebrew_core_url = "https://github.com/#{tap_full_name}"
|
homebrew_core_url = "https://github.com/#{tap_full_name}"
|
||||||
@ -139,6 +139,8 @@ module Homebrew
|
|||||||
raise FormulaUnspecifiedError if formula.blank?
|
raise FormulaUnspecifiedError if formula.blank?
|
||||||
|
|
||||||
odie "This formula is disabled!" if formula.disabled?
|
odie "This formula is disabled!" if formula.disabled?
|
||||||
|
odie "This formula is not in a tap!" if formula.tap.blank?
|
||||||
|
odie "This formula's tap is not a Git repository!" unless formula.tap.git?
|
||||||
|
|
||||||
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)
|
||||||
@ -457,7 +459,10 @@ args: args)
|
|||||||
end
|
end
|
||||||
|
|
||||||
def check_open_pull_requests(formula, tap_full_name, args:)
|
def check_open_pull_requests(formula, tap_full_name, args:)
|
||||||
GitHub.check_for_duplicate_pull_requests(formula.name, tap_full_name, state: "open", args: args)
|
GitHub.check_for_duplicate_pull_requests(formula.name, tap_full_name,
|
||||||
|
state: "open",
|
||||||
|
file: formula.path.relative_path_from(formula.tap.path).to_s,
|
||||||
|
args: args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_closed_pull_requests(formula, tap_full_name, args:, version: nil, url: nil, tag: nil)
|
def check_closed_pull_requests(formula, tap_full_name, args:, version: nil, url: nil, tag: nil)
|
||||||
@ -467,7 +472,10 @@ args: args)
|
|||||||
version = Version.detect(url, **specs)
|
version = Version.detect(url, **specs)
|
||||||
end
|
end
|
||||||
# if we haven't already found open requests, try for an exact match across closed requests
|
# if we haven't already found open requests, try for an exact match across closed requests
|
||||||
GitHub.check_for_duplicate_pull_requests("#{formula.name} #{version}", tap_full_name, state: "closed", args: args)
|
GitHub.check_for_duplicate_pull_requests("#{formula.name} #{version}", tap_full_name,
|
||||||
|
state: "closed",
|
||||||
|
file: formula.path.relative_path_from(formula.tap.path).to_s,
|
||||||
|
args: args)
|
||||||
end
|
end
|
||||||
|
|
||||||
def alias_update_pair(formula, new_formula_version)
|
def alias_update_pair(formula, new_formula_version)
|
||||||
|
@ -627,8 +627,12 @@ module GitHub
|
|||||||
[]
|
[]
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_for_duplicate_pull_requests(query, tap_full_name, state:, args:)
|
def check_for_duplicate_pull_requests(query, tap_full_name, state:, file:, args:)
|
||||||
pull_requests = fetch_pull_requests(query, tap_full_name, state: state)
|
pull_requests = fetch_pull_requests(query, tap_full_name, state: state)
|
||||||
|
pull_requests.select! do |pr|
|
||||||
|
pr_files = open_api(url_to("repos", tap_full_name, "pulls", pr["number"], "files"))
|
||||||
|
pr_files.any? { |f| f["filename"] == file }
|
||||||
|
end
|
||||||
return if pull_requests.blank?
|
return if pull_requests.blank?
|
||||||
|
|
||||||
duplicates_message = <<~EOS
|
duplicates_message = <<~EOS
|
||||||
@ -666,16 +670,16 @@ module GitHub
|
|||||||
end
|
end
|
||||||
|
|
||||||
def create_bump_pr(info, args:)
|
def create_bump_pr(info, args:)
|
||||||
|
tap = info[:tap]
|
||||||
sourcefile_path = info[:sourcefile_path]
|
sourcefile_path = info[:sourcefile_path]
|
||||||
old_contents = info[:old_contents]
|
old_contents = info[:old_contents]
|
||||||
additional_files = info[:additional_files] || []
|
additional_files = info[:additional_files] || []
|
||||||
remote = info[:remote] || "origin"
|
remote = info[:remote] || "origin"
|
||||||
remote_branch = info[:remote_branch]
|
remote_branch = info[:remote_branch] || tap.path.git_origin_branch
|
||||||
branch = info[:branch_name]
|
branch = info[:branch_name]
|
||||||
commit_message = info[:commit_message]
|
commit_message = info[:commit_message]
|
||||||
previous_branch = info[:previous_branch]
|
previous_branch = info[:previous_branch] || "-"
|
||||||
tap = info[:tap]
|
tap_full_name = info[:tap_full_name] || tap.full_name
|
||||||
tap_full_name = info[:tap_full_name]
|
|
||||||
pr_message = info[:pr_message]
|
pr_message = info[:pr_message]
|
||||||
|
|
||||||
sourcefile_path.parent.cd do
|
sourcefile_path.parent.cd do
|
||||||
|
Loading…
x
Reference in New Issue
Block a user