Merge pull request #16664 from Homebrew/bump_no_force

dev-cmd/bump*: do not allow forcing multiple PRs.
This commit is contained in:
Mike McQuaid 2024-02-16 08:29:54 +00:00 committed by GitHub
commit eebd844d6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
9 changed files with 23 additions and 27 deletions

View File

@ -52,7 +52,7 @@ module Homebrew
flag "--fork-org=",
description: "Use the specified GitHub organization for forking."
switch "-f", "--force",
description: "Ignore duplicate open PRs."
hidden: true
conflicts "--dry-run", "--write"
conflicts "--no-audit", "--online"
@ -68,6 +68,7 @@ module Homebrew
args = bump_cask_pr_args.parse
odeprecated "brew bump-cask-pr --online" if args.online?
odisabled "brew bump-cask-pr --force" if args.force?
# This will be run by `brew audit` or `brew style` later so run it first to
# not start spamming during normal output.
@ -252,7 +253,7 @@ module Homebrew
state: "open",
version: nil,
file: cask.sourcefile_path.relative_path_from(cask.tap.path).to_s,
args: args)
quiet: args.quiet?)
# if we haven't already found open requests, try for an exact match across closed requests
new_version.instance_variables.each do |version_type|
@ -265,7 +266,7 @@ module Homebrew
state: "closed",
version: shortened_version(version, cask: cask),
file: cask.sourcefile_path.relative_path_from(cask.tap.path).to_s,
args: args,
quiet: args.quiet?,
)
end
end

View File

@ -71,7 +71,7 @@ module Homebrew
description: "Specify the new commit <revision> corresponding to the specified git <tag> " \
"or specified <version>."
switch "-f", "--force",
description: "Ignore duplicate open PRs. Remove all mirrors if `--mirror` was not specified."
description: "Remove all mirrors if `--mirror` was not specified."
flag "--python-package-name=",
description: "Use the specified <package-name> when finding Python resources for <formula>. " \
"If no package name is specified, it will be inferred from the formula's stable URL."
@ -433,7 +433,7 @@ module Homebrew
GitHub.check_for_duplicate_pull_requests(formula.name, tap_remote_repo,
state: "open",
file: formula.path.relative_path_from(formula.tap.path).to_s,
args: args)
quiet: args.quiet?)
end
def check_new_version(formula, tap_remote_repo, args:, version: nil, url: nil, tag: nil)
@ -464,7 +464,7 @@ module Homebrew
version: version,
state: "closed",
file: formula.path.relative_path_from(formula.tap.path).to_s,
args: args)
quiet: args.quiet?)
end
def alias_update_pair(formula, new_formula_version)

View File

@ -44,7 +44,6 @@ module Homebrew
flag "--start-with=",
description: "Letter or word that the list of package results should alphabetically follow."
switch "-f", "--force",
description: "Ignore duplicate open PRs.",
hidden: true
conflicts "--cask", "--formula"
@ -64,6 +63,8 @@ module Homebrew
raise UsageError, "`--limit` must be used with either `--formula` or `--cask`."
end
odisabled "brew bump --force" if args.force?
Homebrew.with_no_api_env do
formulae_and_casks = if args.installed?
formulae = args.cask? ? [] : Formula.installed
@ -492,7 +493,7 @@ module Homebrew
return
end
return if !args.force? && (open_pull_requests.present? || closed_pull_requests.present?)
return if open_pull_requests.present? || closed_pull_requests.present?
version_args = if version_info.multiple_versions
%W[--version-arm=#{new_version.arm} --version-intel=#{new_version.intel}]
@ -507,7 +508,6 @@ module Homebrew
"--no-browse",
"--message=Created by `brew bump`",
]
bump_cask_pr_args << "--force" if args.force?
system HOMEBREW_BREW_FILE, *bump_cask_pr_args
end

View File

@ -553,7 +553,7 @@ module GitHub
@open_pull_requests[cache_key].select { |pr| regex.match?(pr["title"]) }
end
def self.check_for_duplicate_pull_requests(name, tap_remote_repo, state:, file:, args:, version: nil)
def self.check_for_duplicate_pull_requests(name, tap_remote_repo, state:, file:, quiet:, version: nil)
# `fetch_open_pull_requests` is more reliable but *really* slow, so let's use it only in CI.
pull_requests = if state == "open" && ENV["CI"].present?
fetch_open_pull_requests(name, tap_remote_repo, version: version)
@ -568,16 +568,20 @@ module GitHub
end
return if pull_requests.blank?
force = ENV.fetch("HOMEBREW_TEST_BOT_AUTOBUMP", nil).present?
duplicates_message = <<~EOS
These #{state} pull requests may be duplicates:
#{pull_requests.map { |pr| "#{pr["title"]} #{pr["html_url"]}" }.join("\n")}
EOS
error_message = "Duplicate PRs should not be opened. Use `--force` to override this error."
if args.force? && !args.quiet?
error_message = <<~EOS
Duplicate PRs should not be opened.
Manually open these PRs if you are sure that they are not duplicates.
EOS
if force && !quiet
opoo duplicates_message
elsif !args.force? && args.quiet?
elsif !force && quiet
odie error_message
elsif !args.force?
elsif !force
odie <<~EOS
#{duplicates_message.chomp}
#{error_message}

View File

@ -465,7 +465,6 @@ _brew_bump_cask_pr() {
--commit
--debug
--dry-run
--force
--fork-org
--help
--message

View File

@ -396,7 +396,6 @@ __fish_brew_complete_cmd 'bump-cask-pr' 'Create a pull request to update cask wi
__fish_brew_complete_arg 'bump-cask-pr' -l commit -d 'When passed with `--write-only`, generate a new commit after writing changes to the cask file'
__fish_brew_complete_arg 'bump-cask-pr' -l debug -d 'Display any debugging information'
__fish_brew_complete_arg 'bump-cask-pr' -l dry-run -d 'Print what would be done rather than doing it'
__fish_brew_complete_arg 'bump-cask-pr' -l force -d 'Ignore duplicate open PRs'
__fish_brew_complete_arg 'bump-cask-pr' -l fork-org -d 'Use the specified GitHub organization for forking'
__fish_brew_complete_arg 'bump-cask-pr' -l help -d 'Show this message'
__fish_brew_complete_arg 'bump-cask-pr' -l message -d 'Prepend message to the default pull request message'
@ -419,7 +418,7 @@ __fish_brew_complete_cmd 'bump-formula-pr' 'Create a pull request to update form
__fish_brew_complete_arg 'bump-formula-pr' -l commit -d 'When passed with `--write-only`, generate a new commit after writing changes to the formula file'
__fish_brew_complete_arg 'bump-formula-pr' -l debug -d 'Display any debugging information'
__fish_brew_complete_arg 'bump-formula-pr' -l dry-run -d 'Print what would be done rather than doing it'
__fish_brew_complete_arg 'bump-formula-pr' -l force -d 'Ignore duplicate open PRs. Remove all mirrors if `--mirror` was not specified'
__fish_brew_complete_arg 'bump-formula-pr' -l force -d 'Remove all mirrors if `--mirror` was not specified'
__fish_brew_complete_arg 'bump-formula-pr' -l fork-org -d 'Use the specified GitHub organization for forking'
__fish_brew_complete_arg 'bump-formula-pr' -l help -d 'Show this message'
__fish_brew_complete_arg 'bump-formula-pr' -l message -d 'Prepend message to the default pull request message'

View File

@ -517,7 +517,6 @@ _brew_bump_cask_pr() {
'--commit[When passed with `--write-only`, generate a new commit after writing changes to the cask file]' \
'--debug[Display any debugging information]' \
'(--write)--dry-run[Print what would be done rather than doing it]' \
'--force[Ignore duplicate open PRs]' \
'--fork-org[Use the specified GitHub organization for forking]' \
'--help[Show this message]' \
'--message[Prepend message to the default pull request message]' \
@ -543,7 +542,7 @@ _brew_bump_formula_pr() {
'--commit[When passed with `--write-only`, generate a new commit after writing changes to the formula file]' \
'--debug[Display any debugging information]' \
'(--write-only)--dry-run[Print what would be done rather than doing it]' \
'--force[Ignore duplicate open PRs. Remove all mirrors if `--mirror` was not specified]' \
'--force[Remove all mirrors if `--mirror` was not specified]' \
'--fork-org[Use the specified GitHub organization for forking]' \
'--help[Show this message]' \
'--message[Prepend message to the default pull request message]' \

View File

@ -1073,8 +1073,6 @@ supplied by the user.
Specify the *`SHA-256`* checksum of the new download.
* `--fork-org`:
Use the specified GitHub organization for forking.
* `-f`, `--force`:
Ignore duplicate open PRs.
### `bump-formula-pr` [*`options`*] [*`formula`*]
@ -1128,7 +1126,7 @@ nor vice versa. It must use whichever style specification the formula already us
* `--revision`:
Specify the new commit *`revision`* corresponding to the specified git *`tag`* or specified *`version`*.
* `-f`, `--force`:
Ignore duplicate open PRs. Remove all mirrors if `--mirror` was not specified.
Remove all mirrors if `--mirror` was not specified.
* `--python-package-name`:
Use the specified *`package-name`* when finding Python resources for *`formula`*. If no package name is specified, it will be inferred from the formula's stable URL.
* `--python-extra-packages`:

View File

@ -1534,10 +1534,6 @@ Specify the \fISHA\-256\fR checksum of the new download\.
\fB\-\-fork\-org\fR
Use the specified GitHub organization for forking\.
.
.TP
\fB\-f\fR, \fB\-\-force\fR
Ignore duplicate open PRs\.
.
.SS "\fBbump\-formula\-pr\fR [\fIoptions\fR] [\fIformula\fR]"
Create a pull request to update \fIformula\fR with a new URL or a new tag\.
.
@ -1619,7 +1615,7 @@ Specify the new commit \fIrevision\fR corresponding to the specified git \fItag\
.
.TP
\fB\-f\fR, \fB\-\-force\fR
Ignore duplicate open PRs\. Remove all mirrors if \fB\-\-mirror\fR was not specified\.
Remove all mirrors if \fB\-\-mirror\fR was not specified\.
.
.TP
\fB\-\-python\-package\-name\fR