Merge pull request #20082 from alex/strict-check-for-duplicate-prs

Add strict parameter to `GitHub::check_for_duplicate_pull_requests`
This commit is contained in:
Mike McQuaid 2025-06-12 13:23:17 +00:00 committed by GitHub
commit 1a5afaf739
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -627,6 +627,12 @@ module GitHub
pull_requests || []
end
# Check for duplicate pull requests that modify the same file.
#
# Exits the process on duplicates if `strict` or both `version` and
# `official_tap`, otherwise warns.
#
# @api internal
sig {
params(
name: String,
@ -636,10 +642,11 @@ module GitHub
state: T.nilable(String),
version: T.nilable(String),
official_tap: T::Boolean,
strict: T::Boolean,
).void
}
def self.check_for_duplicate_pull_requests(name, tap_remote_repo, file:, quiet: false, state: nil,
version: nil, official_tap: true)
version: nil, official_tap: true, strict: false)
pull_requests = fetch_pull_requests(name, tap_remote_repo, state:, version:)
pull_requests.select! do |pr|
@ -659,13 +666,13 @@ module GitHub
Manually open these PRs if you are sure that they are not duplicates (and tell us that in the PR).
EOS
if !official_tap
opoo duplicates_message
elsif version
if strict || (version && official_tap)
odie <<~EOS
#{duplicates_message.chomp}
#{error_message}
EOS
elsif !official_tap
opoo duplicates_message
elsif quiet
opoo error_message
else