From 108ecf9aac8ab07c0c75bf0689a92ab86d5187f9 Mon Sep 17 00:00:00 2001 From: Mike McQuaid Date: Tue, 1 Apr 2025 11:01:17 +0100 Subject: [PATCH] dev-cmd/bump-*: only warn on duplicate PRs for official taps. The default behaviour is too strict for unofficial taps. We can still warn elsewhere but, given the potential for false positives, let's loosen things a bit. --- Library/Homebrew/dev-cmd/bump-cask-pr.rb | 6 ++++-- Library/Homebrew/dev-cmd/bump-formula-pr.rb | 5 +++-- Library/Homebrew/utils/github.rb | 8 ++++++-- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/Library/Homebrew/dev-cmd/bump-cask-pr.rb b/Library/Homebrew/dev-cmd/bump-cask-pr.rb index cbc0f89989..1c0f11024d 100644 --- a/Library/Homebrew/dev-cmd/bump-cask-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-cask-pr.rb @@ -259,8 +259,9 @@ module Homebrew file = cask.sourcefile_path.relative_path_from(cask.tap.path).to_s quiet = args.quiet? + official_tap = cask.tap.official? GitHub.check_for_duplicate_pull_requests(cask.token, tap_remote_repo, - state: "open", file:, quiet:) + state: "open", file:, quiet:, official_tap:) # if we haven't already found open requests, try for an exact match across all pull requests new_version.instance_variables.each do |version_type| @@ -268,7 +269,8 @@ module Homebrew next if version_type_version.blank? version = shortened_version(version_type_version, cask:) - GitHub.check_for_duplicate_pull_requests(cask.token, tap_remote_repo, version:, file:, quiet:) + GitHub.check_for_duplicate_pull_requests(cask.token, tap_remote_repo, version:, + file:, quiet:, official_tap:) end end diff --git a/Library/Homebrew/dev-cmd/bump-formula-pr.rb b/Library/Homebrew/dev-cmd/bump-formula-pr.rb index 930248160d..30163d927a 100644 --- a/Library/Homebrew/dev-cmd/bump-formula-pr.rb +++ b/Library/Homebrew/dev-cmd/bump-formula-pr.rb @@ -550,8 +550,9 @@ module Homebrew formula.name, tap_remote_repo, version:, state:, - file: formula.path.relative_path_from(tap.path).to_s, - quiet: args.quiet? + file: formula.path.relative_path_from(tap.path).to_s, + quiet: args.quiet?, + official_tap: tap.official? ) end diff --git a/Library/Homebrew/utils/github.rb b/Library/Homebrew/utils/github.rb index 36a9aa14c1..38114448b4 100644 --- a/Library/Homebrew/utils/github.rb +++ b/Library/Homebrew/utils/github.rb @@ -635,9 +635,11 @@ module GitHub quiet: T::Boolean, state: T.nilable(String), version: T.nilable(String), + official_tap: T::Boolean, ).void } - def self.check_for_duplicate_pull_requests(name, tap_remote_repo, file:, quiet: false, state: nil, version: nil) + def self.check_for_duplicate_pull_requests(name, tap_remote_repo, file:, quiet: false, state: nil, + version: nil, official_tap: true) pull_requests = fetch_pull_requests(name, tap_remote_repo, state:, version:) pull_requests.select! do |pr| @@ -657,7 +659,9 @@ module GitHub Manually open these PRs if you are sure that they are not duplicates (and tell us that in the PR). EOS - if version + if !official_tap + opoo duplicates_message + elsif version odie <<~EOS #{duplicates_message.chomp} #{error_message}