Merge pull request #16664 from Homebrew/bump_no_force
dev-cmd/bump*: do not allow forcing multiple PRs.
This commit is contained in:
commit
eebd844d6e
@ -52,7 +52,7 @@ module Homebrew
|
|||||||
flag "--fork-org=",
|
flag "--fork-org=",
|
||||||
description: "Use the specified GitHub organization for forking."
|
description: "Use the specified GitHub organization for forking."
|
||||||
switch "-f", "--force",
|
switch "-f", "--force",
|
||||||
description: "Ignore duplicate open PRs."
|
hidden: true
|
||||||
|
|
||||||
conflicts "--dry-run", "--write"
|
conflicts "--dry-run", "--write"
|
||||||
conflicts "--no-audit", "--online"
|
conflicts "--no-audit", "--online"
|
||||||
@ -68,6 +68,7 @@ module Homebrew
|
|||||||
args = bump_cask_pr_args.parse
|
args = bump_cask_pr_args.parse
|
||||||
|
|
||||||
odeprecated "brew bump-cask-pr --online" if args.online?
|
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
|
# This will be run by `brew audit` or `brew style` later so run it first to
|
||||||
# not start spamming during normal output.
|
# not start spamming during normal output.
|
||||||
@ -252,7 +253,7 @@ module Homebrew
|
|||||||
state: "open",
|
state: "open",
|
||||||
version: nil,
|
version: nil,
|
||||||
file: cask.sourcefile_path.relative_path_from(cask.tap.path).to_s,
|
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
|
# if we haven't already found open requests, try for an exact match across closed requests
|
||||||
new_version.instance_variables.each do |version_type|
|
new_version.instance_variables.each do |version_type|
|
||||||
@ -265,7 +266,7 @@ module Homebrew
|
|||||||
state: "closed",
|
state: "closed",
|
||||||
version: shortened_version(version, cask: cask),
|
version: shortened_version(version, cask: cask),
|
||||||
file: cask.sourcefile_path.relative_path_from(cask.tap.path).to_s,
|
file: cask.sourcefile_path.relative_path_from(cask.tap.path).to_s,
|
||||||
args: args,
|
quiet: args.quiet?,
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -71,7 +71,7 @@ module Homebrew
|
|||||||
description: "Specify the new commit <revision> corresponding to the specified git <tag> " \
|
description: "Specify the new commit <revision> corresponding to the specified git <tag> " \
|
||||||
"or specified <version>."
|
"or specified <version>."
|
||||||
switch "-f", "--force",
|
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=",
|
flag "--python-package-name=",
|
||||||
description: "Use the specified <package-name> when finding Python resources for <formula>. " \
|
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."
|
"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,
|
GitHub.check_for_duplicate_pull_requests(formula.name, tap_remote_repo,
|
||||||
state: "open",
|
state: "open",
|
||||||
file: formula.path.relative_path_from(formula.tap.path).to_s,
|
file: formula.path.relative_path_from(formula.tap.path).to_s,
|
||||||
args: args)
|
quiet: args.quiet?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_new_version(formula, tap_remote_repo, args:, version: nil, url: nil, tag: nil)
|
def check_new_version(formula, tap_remote_repo, args:, version: nil, url: nil, tag: nil)
|
||||||
@ -464,7 +464,7 @@ module Homebrew
|
|||||||
version: version,
|
version: version,
|
||||||
state: "closed",
|
state: "closed",
|
||||||
file: formula.path.relative_path_from(formula.tap.path).to_s,
|
file: formula.path.relative_path_from(formula.tap.path).to_s,
|
||||||
args: args)
|
quiet: args.quiet?)
|
||||||
end
|
end
|
||||||
|
|
||||||
def alias_update_pair(formula, new_formula_version)
|
def alias_update_pair(formula, new_formula_version)
|
||||||
|
@ -44,7 +44,6 @@ module Homebrew
|
|||||||
flag "--start-with=",
|
flag "--start-with=",
|
||||||
description: "Letter or word that the list of package results should alphabetically follow."
|
description: "Letter or word that the list of package results should alphabetically follow."
|
||||||
switch "-f", "--force",
|
switch "-f", "--force",
|
||||||
description: "Ignore duplicate open PRs.",
|
|
||||||
hidden: true
|
hidden: true
|
||||||
|
|
||||||
conflicts "--cask", "--formula"
|
conflicts "--cask", "--formula"
|
||||||
@ -64,6 +63,8 @@ module Homebrew
|
|||||||
raise UsageError, "`--limit` must be used with either `--formula` or `--cask`."
|
raise UsageError, "`--limit` must be used with either `--formula` or `--cask`."
|
||||||
end
|
end
|
||||||
|
|
||||||
|
odisabled "brew bump --force" if args.force?
|
||||||
|
|
||||||
Homebrew.with_no_api_env do
|
Homebrew.with_no_api_env do
|
||||||
formulae_and_casks = if args.installed?
|
formulae_and_casks = if args.installed?
|
||||||
formulae = args.cask? ? [] : Formula.installed
|
formulae = args.cask? ? [] : Formula.installed
|
||||||
@ -492,7 +493,7 @@ module Homebrew
|
|||||||
return
|
return
|
||||||
end
|
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
|
version_args = if version_info.multiple_versions
|
||||||
%W[--version-arm=#{new_version.arm} --version-intel=#{new_version.intel}]
|
%W[--version-arm=#{new_version.arm} --version-intel=#{new_version.intel}]
|
||||||
@ -507,7 +508,6 @@ module Homebrew
|
|||||||
"--no-browse",
|
"--no-browse",
|
||||||
"--message=Created by `brew bump`",
|
"--message=Created by `brew bump`",
|
||||||
]
|
]
|
||||||
bump_cask_pr_args << "--force" if args.force?
|
|
||||||
|
|
||||||
system HOMEBREW_BREW_FILE, *bump_cask_pr_args
|
system HOMEBREW_BREW_FILE, *bump_cask_pr_args
|
||||||
end
|
end
|
||||||
|
@ -553,7 +553,7 @@ module GitHub
|
|||||||
@open_pull_requests[cache_key].select { |pr| regex.match?(pr["title"]) }
|
@open_pull_requests[cache_key].select { |pr| regex.match?(pr["title"]) }
|
||||||
end
|
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.
|
# `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?
|
pull_requests = if state == "open" && ENV["CI"].present?
|
||||||
fetch_open_pull_requests(name, tap_remote_repo, version: version)
|
fetch_open_pull_requests(name, tap_remote_repo, version: version)
|
||||||
@ -568,16 +568,20 @@ module GitHub
|
|||||||
end
|
end
|
||||||
return if pull_requests.blank?
|
return if pull_requests.blank?
|
||||||
|
|
||||||
|
force = ENV.fetch("HOMEBREW_TEST_BOT_AUTOBUMP", nil).present?
|
||||||
duplicates_message = <<~EOS
|
duplicates_message = <<~EOS
|
||||||
These #{state} pull requests may be duplicates:
|
These #{state} pull requests may be duplicates:
|
||||||
#{pull_requests.map { |pr| "#{pr["title"]} #{pr["html_url"]}" }.join("\n")}
|
#{pull_requests.map { |pr| "#{pr["title"]} #{pr["html_url"]}" }.join("\n")}
|
||||||
EOS
|
EOS
|
||||||
error_message = "Duplicate PRs should not be opened. Use `--force` to override this error."
|
error_message = <<~EOS
|
||||||
if args.force? && !args.quiet?
|
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
|
opoo duplicates_message
|
||||||
elsif !args.force? && args.quiet?
|
elsif !force && quiet
|
||||||
odie error_message
|
odie error_message
|
||||||
elsif !args.force?
|
elsif !force
|
||||||
odie <<~EOS
|
odie <<~EOS
|
||||||
#{duplicates_message.chomp}
|
#{duplicates_message.chomp}
|
||||||
#{error_message}
|
#{error_message}
|
||||||
|
@ -465,7 +465,6 @@ _brew_bump_cask_pr() {
|
|||||||
--commit
|
--commit
|
||||||
--debug
|
--debug
|
||||||
--dry-run
|
--dry-run
|
||||||
--force
|
|
||||||
--fork-org
|
--fork-org
|
||||||
--help
|
--help
|
||||||
--message
|
--message
|
||||||
|
@ -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 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 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 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 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 help -d 'Show this message'
|
||||||
__fish_brew_complete_arg 'bump-cask-pr' -l message -d 'Prepend message to the default pull request 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 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 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 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 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 help -d 'Show this message'
|
||||||
__fish_brew_complete_arg 'bump-formula-pr' -l message -d 'Prepend message to the default pull request message'
|
__fish_brew_complete_arg 'bump-formula-pr' -l message -d 'Prepend message to the default pull request message'
|
||||||
|
@ -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]' \
|
'--commit[When passed with `--write-only`, generate a new commit after writing changes to the cask file]' \
|
||||||
'--debug[Display any debugging information]' \
|
'--debug[Display any debugging information]' \
|
||||||
'(--write)--dry-run[Print what would be done rather than doing it]' \
|
'(--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]' \
|
'--fork-org[Use the specified GitHub organization for forking]' \
|
||||||
'--help[Show this message]' \
|
'--help[Show this message]' \
|
||||||
'--message[Prepend message to the default pull request 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]' \
|
'--commit[When passed with `--write-only`, generate a new commit after writing changes to the formula file]' \
|
||||||
'--debug[Display any debugging information]' \
|
'--debug[Display any debugging information]' \
|
||||||
'(--write-only)--dry-run[Print what would be done rather than doing it]' \
|
'(--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]' \
|
'--fork-org[Use the specified GitHub organization for forking]' \
|
||||||
'--help[Show this message]' \
|
'--help[Show this message]' \
|
||||||
'--message[Prepend message to the default pull request message]' \
|
'--message[Prepend message to the default pull request message]' \
|
||||||
|
@ -1073,8 +1073,6 @@ supplied by the user.
|
|||||||
Specify the *`SHA-256`* checksum of the new download.
|
Specify the *`SHA-256`* checksum of the new download.
|
||||||
* `--fork-org`:
|
* `--fork-org`:
|
||||||
Use the specified GitHub organization for forking.
|
Use the specified GitHub organization for forking.
|
||||||
* `-f`, `--force`:
|
|
||||||
Ignore duplicate open PRs.
|
|
||||||
|
|
||||||
### `bump-formula-pr` [*`options`*] [*`formula`*]
|
### `bump-formula-pr` [*`options`*] [*`formula`*]
|
||||||
|
|
||||||
@ -1128,7 +1126,7 @@ nor vice versa. It must use whichever style specification the formula already us
|
|||||||
* `--revision`:
|
* `--revision`:
|
||||||
Specify the new commit *`revision`* corresponding to the specified git *`tag`* or specified *`version`*.
|
Specify the new commit *`revision`* corresponding to the specified git *`tag`* or specified *`version`*.
|
||||||
* `-f`, `--force`:
|
* `-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`:
|
* `--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.
|
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`:
|
* `--python-extra-packages`:
|
||||||
|
@ -1534,10 +1534,6 @@ Specify the \fISHA\-256\fR checksum of the new download\.
|
|||||||
\fB\-\-fork\-org\fR
|
\fB\-\-fork\-org\fR
|
||||||
Use the specified GitHub organization for forking\.
|
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]"
|
.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\.
|
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
|
.TP
|
||||||
\fB\-f\fR, \fB\-\-force\fR
|
\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
|
.TP
|
||||||
\fB\-\-python\-package\-name\fR
|
\fB\-\-python\-package\-name\fR
|
||||||
|
Loading…
x
Reference in New Issue
Block a user