github/pr-pull: fix/improve parameters

Fixes #13634
This commit is contained in:
Michka Popoff 2022-08-03 14:02:01 +02:00
parent ba7e146eef
commit 756c2b2c52
No known key found for this signature in database
GPG Key ID: 033D03F151030611
2 changed files with 8 additions and 8 deletions

View File

@ -368,26 +368,26 @@ module Homebrew
end
end
def pr_check_conflicts(name, tap_remote_repo, pr)
def pr_check_conflicts(user, repo, pr)
hash_template = proc { |h, k| h[k] = [] }
long_build_pr_files = GitHub.search_issues(
"org:#{name}", repo: tap_remote_repo, state: "open", label: "\"no long build conflict\""
"org:#{user}", repo: repo, state: "open", label: "\"no long build conflict\""
).each_with_object(Hash.new(hash_template)) do |long_build_pr, hash|
number = long_build_pr["number"]
GitHub.get_pull_request_changed_files(name, tap_remote_repo, number).each do |file|
GitHub.get_pull_request_changed_files("#{user}/#{repo}", number).each do |file|
key = file["filename"]
hash[key] << number
end
end
this_pr_files = GitHub.get_pull_request_changed_files(name, tap_remote_repo, pr)
this_pr_files = GitHub.get_pull_request_changed_files("#{user}/#{repo}", pr)
conflicts = this_pr_files.each_with_object(Hash.new(hash_template)) do |file, hash|
filename = file["filename"]
next unless long_build_pr_files.key?(filename)
long_build_pr_files[filename].each do |pr_number|
key = "#{tap_remote_repo}/pull/#{pr_number}"
key = "#{user}/#{repo}/pull/#{pr_number}"
hash[key] << filename
end
end

View File

@ -480,7 +480,7 @@ module GitHub
def check_for_duplicate_pull_requests(name, tap_remote_repo, state:, file:, args:, version: nil)
pull_requests = fetch_pull_requests(name, tap_remote_repo, state: state, version: version).select do |pr|
get_pull_request_changed_files(
name, tap_remote_repo, pr["number"]
tap_remote_repo, pr["number"]
).any? { |f| f["filename"] == file }
end
return if pull_requests.blank?
@ -502,8 +502,8 @@ module GitHub
end
end
def get_pull_request_changed_files(name, tap_remote_repo, pr)
API.open_rest(url_to("repos", name, tap_remote_repo, "pulls", pr, "files"))
def get_pull_request_changed_files(tap_remote_repo, pr)
API.open_rest(url_to("repos", tap_remote_repo, "pulls", pr, "files"))
end
def forked_repo_info!(tap_remote_repo, org: nil)