Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/bump: add --installed flag #15829

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 26 additions & 17 deletions Library/Homebrew/dev-cmd/bump.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@
description: "Check only formulae."
switch "--cask", "--casks",
description: "Check only casks."
switch "--installed",
description: "Check formulae and casks that are currently installed."
switch "--open-pr",
description: "Open a pull request for the new version if none have been opened yet."
flag "--limit=",
Expand All @@ -60,26 +62,33 @@
raise UsageError, "`--limit` must be used with either `--formula` or `--cask`."
end

formulae_and_casks = if args.formula?
args.named.to_formulae
elsif args.cask?
args.named.to_casks
else
args.named.to_formulae_and_casks
end
formulae_and_casks = formulae_and_casks&.sort_by do |formula_or_cask|
formula_or_cask.respond_to?(:token) ? formula_or_cask.token : formula_or_cask.name
end
Homebrew.with_no_api_env do
formulae_and_casks = if args.installed?

Check warning on line 66 in Library/Homebrew/dev-cmd/bump.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bump.rb#L65-L66

Added lines #L65 - L66 were not covered by tests
formulae = args.cask? ? [] : Formula.installed
casks = args.formula? ? [] : Cask::Caskroom.casks
formulae + casks

Check warning on line 69 in Library/Homebrew/dev-cmd/bump.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bump.rb#L69

Added line #L69 was not covered by tests
elsif args.named.present?
if args.formula?
args.named.to_formulae
elsif args.cask?
args.named.to_casks
else
args.named.to_formulae_and_casks
end
end

unless Utils::Curl.curl_supports_tls13?
begin
ensure_formula_installed!("curl", reason: "Repology queries") unless HOMEBREW_BREWED_CURL_PATH.exist?
rescue FormulaUnavailableError
opoo "A newer `curl` is required for Repology queries."
formulae_and_casks = formulae_and_casks&.sort_by do |formula_or_cask|
formula_or_cask.respond_to?(:token) ? formula_or_cask.token : formula_or_cask.name
end

unless Utils::Curl.curl_supports_tls13?
begin
ensure_formula_installed!("curl", reason: "Repology queries") unless HOMEBREW_BREWED_CURL_PATH.exist?
rescue FormulaUnavailableError
opoo "A newer `curl` is required for Repology queries."

Check warning on line 88 in Library/Homebrew/dev-cmd/bump.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/dev-cmd/bump.rb#L88

Added line #L88 was not covered by tests
end
end
end

Homebrew.with_no_api_env do
if formulae_and_casks.present?
handle_formula_and_casks(formulae_and_casks, args)
else
Expand Down
1 change: 1 addition & 0 deletions completions/bash/brew
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,7 @@ _brew_bump() {
--formula
--full-name
--help
--installed
--limit
--no-pull-requests
--open-pr
Expand Down
1 change: 1 addition & 0 deletions completions/fish/brew.fish
Original file line number Diff line number Diff line change
Expand Up @@ -384,6 +384,7 @@ __fish_brew_complete_arg 'bump' -l debug -d 'Display any debugging information'
__fish_brew_complete_arg 'bump' -l formula -d 'Check only formulae'
__fish_brew_complete_arg 'bump' -l full-name -d 'Print formulae/casks with fully-qualified names'
__fish_brew_complete_arg 'bump' -l help -d 'Show this message'
__fish_brew_complete_arg 'bump' -l installed -d 'Check formulae and casks that are currently installed'
__fish_brew_complete_arg 'bump' -l limit -d 'Limit number of package results returned'
__fish_brew_complete_arg 'bump' -l no-pull-requests -d 'Do not retrieve pull requests from GitHub'
__fish_brew_complete_arg 'bump' -l open-pr -d 'Open a pull request for the new version if none have been opened yet'
Expand Down
1 change: 1 addition & 0 deletions completions/zsh/_brew
Original file line number Diff line number Diff line change
Expand Up @@ -495,6 +495,7 @@ _brew_bump() {
'--debug[Display any debugging information]' \
'--full-name[Print formulae/casks with fully-qualified names]' \
'--help[Show this message]' \
'--installed[Check formulae and casks that are currently installed]' \
'--limit[Limit number of package results returned]' \
'(--open-pr)--no-pull-requests[Do not retrieve pull requests from GitHub]' \
'(--no-pull-requests)--open-pr[Open a pull request for the new version if none have been opened yet]' \
Expand Down
2 changes: 2 additions & 0 deletions docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,8 @@ formulae, also displays whether a pull request has been opened with the URL.
Check only formulae.
* `--cask`:
Check only casks.
* `--installed`:
Check formulae and casks that are currently installed.
* `--open-pr`:
Open a pull request for the new version if none have been opened yet.
* `--limit`:
Expand Down
4 changes: 4 additions & 0 deletions manpages/brew.1
Original file line number Diff line number Diff line change
Expand Up @@ -1443,6 +1443,10 @@ Check only formulae\.
Check only casks\.
.
.TP
\fB\-\-installed\fR
Check formulae and casks that are currently installed\.
.
.TP
\fB\-\-open\-pr\fR
Open a pull request for the new version if none have been opened yet\.
.
Expand Down
Loading