Skip to content

Commit

Permalink
livecheck: introduce --extract-plist
Browse files Browse the repository at this point in the history
make --no-extract-plist behavior the default
remove explicit --no-extract-plist option
suggestions from code review
  • Loading branch information
razvanazamfirei committed Mar 20, 2024
1 parent c42ff0f commit bf76e51
Show file tree
Hide file tree
Showing 7 changed files with 25 additions and 305 deletions.
8 changes: 4 additions & 4 deletions Library/Homebrew/dev-cmd/livecheck.rb
Expand Up @@ -38,13 +38,13 @@ def livecheck_args
description: "Only check formulae."
switch "--cask", "--casks",
description: "Only check casks."
switch "--no-extract-plist",
description: "Exclude casks using the ExtractPlist livecheck strategy."
switch "--extract-plist",
description: "Include casks using the ExtractPlist livecheck strategy."

conflicts "--debug", "--json"
conflicts "--tap=", "--eval-all", "--installed"
conflicts "--cask", "--formula"
conflicts "--formula", "--no-extract-plist"
conflicts "--formula", "--extract-plist"

named_args [:formula, :cask], without_api: true
end
Expand Down Expand Up @@ -128,10 +128,10 @@ def livecheck
handle_name_conflict: !args.formula? && !args.cask?,
check_resources: args.resources?,
newer_only: args.newer_only?,
extract_plist: args.extract_plist?,
quiet: args.quiet?,
debug: args.debug?,
verbose: args.verbose?,
no_extract_plist: args.no_extract_plist?,
}.compact

Livecheck.run_checks(formulae_and_casks_to_check, **options)
Expand Down
16 changes: 9 additions & 7 deletions Library/Homebrew/livecheck/livecheck.rb
Expand Up @@ -167,16 +167,16 @@ def resolve_livecheck_reference(
check_resources: T::Boolean,
json: T::Boolean,
newer_only: T::Boolean,
extract_plist: T::Boolean,
debug: T::Boolean,
quiet: T::Boolean,
verbose: T::Boolean,
no_extract_plist: T::Boolean,
).void
}
def run_checks(
formulae_and_casks_to_check,
full_name: false, handle_name_conflict: false, check_resources: false, json: false, newer_only: false,
debug: false, quiet: false, verbose: false, no_extract_plist: false
extract_plist: false, debug: false, quiet: false, verbose: false
)
load_other_tap_strategies(formulae_and_casks_to_check)

Expand All @@ -198,12 +198,11 @@ def run_checks(
.select { |items| items.length > 1 }
.flatten
end
formulae_and_casks_total = formulae_and_casks_to_check.count

has_a_newer_upstream_version = T.let(false, T::Boolean)

if json && !quiet && $stderr.tty?
formulae_and_casks_total = formulae_and_casks_to_check.count

Tty.with($stderr) do |stderr|
stderr.puts Formatter.headline("Running checks", color: :blue)
end
Expand All @@ -218,6 +217,9 @@ def run_checks(
)
end

# If only one formula/cask is being checked, we enable extract-plist
extract_plist = true if formulae_and_casks_total == 1

formulae_checked = formulae_and_casks_to_check.map.with_index do |formula_or_cask, i|
formula = formula_or_cask if formula_or_cask.is_a?(Formula)
cask = formula_or_cask if formula_or_cask.is_a?(Cask::Cask)
Expand All @@ -238,11 +240,11 @@ def run_checks(
puts
end

if cask && no_extract_plist && formula_or_cask.livecheck.strategy == :extract_plist
if cask && !extract_plist && formula_or_cask.livecheck.strategy == :extract_plist
skip_info = {
cask: cask.token.to_s,
cask: cask.token,

Check warning on line 245 in Library/Homebrew/livecheck/livecheck.rb

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/livecheck/livecheck.rb#L245

Added line #L245 was not covered by tests
status: "skipped",
messages: ["Livecheck skipped due to --no-plist"],
messages: ["Livecheck skipped due to the ExtractPlist strategy"],
meta: { livecheckable: true },
}

Expand Down
81 changes: 2 additions & 79 deletions completions/bash/brew
Expand Up @@ -1330,13 +1330,13 @@ _brew_lc() {
--cask
--debug
--eval-all
--extract-plist
--formula
--full-name
--help
--installed
--json
--newer-only
--no-extract-plist
--quiet
--resources
--tap
Expand Down Expand Up @@ -1410,34 +1410,6 @@ _brew_linkage() {
__brew_complete_installed_formulae
}

_brew_list() {
local cur="${COMP_WORDS[COMP_CWORD]}"
case "${cur}" in
-*)
__brewcomp "
--cask
--debug
--formula
--full-name
--help
--multiple
--pinned
--quiet
--verbose
--versions
-1
-l
-r
-t
"
return
;;
*) ;;
esac
__brew_complete_installed_formulae
__brew_complete_installed_casks
}

_brew_livecheck() {
local cur="${COMP_WORDS[COMP_CWORD]}"
case "${cur}" in
Expand All @@ -1446,13 +1418,13 @@ _brew_livecheck() {
--cask
--debug
--eval-all
--extract-plist
--formula
--full-name
--help
--installed
--json
--newer-only
--no-extract-plist
--quiet
--resources
--tap
Expand Down Expand Up @@ -1512,34 +1484,6 @@ _brew_log() {
__brew_complete_casks
}

_brew_ls() {
local cur="${COMP_WORDS[COMP_CWORD]}"
case "${cur}" in
-*)
__brewcomp "
--cask
--debug
--formula
--full-name
--help
--multiple
--pinned
--quiet
--verbose
--versions
-1
-l
-r
-t
"
return
;;
*) ;;
esac
__brew_complete_installed_formulae
__brew_complete_installed_casks
}

_brew_migrate() {
local cur="${COMP_WORDS[COMP_CWORD]}"
case "${cur}" in
Expand Down Expand Up @@ -1814,24 +1758,6 @@ _brew_pr_upload() {
esac
}

_brew_prof() {
local cur="${COMP_WORDS[COMP_CWORD]}"
case "${cur}" in
-*)
__brewcomp "
--debug
--help
--quiet
--stackprof
--verbose
"
return
;;
*) ;;
esac
__brew_complete_commands
}

_brew_pyenv_sync() {
local cur="${COMP_WORDS[COMP_CWORD]}"
case "${cur}" in
Expand Down Expand Up @@ -2727,11 +2653,9 @@ _brew() {
leaves) _brew_leaves ;;
link) _brew_link ;;
linkage) _brew_linkage ;;
list) _brew_list ;;
livecheck) _brew_livecheck ;;
ln) _brew_ln ;;
log) _brew_log ;;
ls) _brew_ls ;;
migrate) _brew_migrate ;;
missing) _brew_missing ;;
nodenv-sync) _brew_nodenv_sync ;;
Expand All @@ -2745,7 +2669,6 @@ _brew() {
pr-publish) _brew_pr_publish ;;
pr-pull) _brew_pr_pull ;;
pr-upload) _brew_pr_upload ;;
prof) _brew_prof ;;
pyenv-sync) _brew_pyenv_sync ;;
rbenv-sync) _brew_rbenv_sync ;;
readall) _brew_readall ;;
Expand Down
51 changes: 2 additions & 49 deletions completions/fish/brew.fish
Expand Up @@ -941,13 +941,13 @@ __fish_brew_complete_cmd 'lc' 'Check for newer versions of formulae and/or casks
__fish_brew_complete_arg 'lc' -l cask -d 'Only check casks'
__fish_brew_complete_arg 'lc' -l debug -d 'Display any debugging information'
__fish_brew_complete_arg 'lc' -l eval-all -d 'Evaluate all available formulae and casks, whether installed or not, to check them'
__fish_brew_complete_arg 'lc' -l extract-plist -d 'Include casks using the ExtractPlist livecheck strategy'
__fish_brew_complete_arg 'lc' -l formula -d 'Only check formulae'
__fish_brew_complete_arg 'lc' -l full-name -d 'Print formulae and casks with fully-qualified names'
__fish_brew_complete_arg 'lc' -l help -d 'Show this message'
__fish_brew_complete_arg 'lc' -l installed -d 'Check formulae and casks that are currently installed'
__fish_brew_complete_arg 'lc' -l json -d 'Output information in JSON format'
__fish_brew_complete_arg 'lc' -l newer-only -d 'Show the latest version only if it\'s newer than the formula/cask'
__fish_brew_complete_arg 'lc' -l no-extract-plist -d 'Exclude casks using the ExtractPlist livecheck strategy'
__fish_brew_complete_arg 'lc' -l quiet -d 'Suppress warnings, don\'t print a progress bar for JSON output'
__fish_brew_complete_arg 'lc' -l resources -d 'Also check resources for formulae'
__fish_brew_complete_arg 'lc' -l tap -d 'Check formulae and casks within the given tap, specified as user`/`repo'
Expand Down Expand Up @@ -989,36 +989,17 @@ __fish_brew_complete_arg 'linkage' -l verbose -d 'Make some output more verbose'
__fish_brew_complete_arg 'linkage' -a '(__fish_brew_suggest_formulae_installed)'


__fish_brew_complete_cmd 'list' 'List all installed formulae and casks'
__fish_brew_complete_arg 'list' -l cask -d 'List only casks, or treat all named arguments as casks'
__fish_brew_complete_arg 'list' -l debug -d 'Display any debugging information'
__fish_brew_complete_arg 'list' -l formula -d 'List only formulae, or treat all named arguments as formulae'
__fish_brew_complete_arg 'list' -l full-name -d 'Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output'
__fish_brew_complete_arg 'list' -l help -d 'Show this message'
__fish_brew_complete_arg 'list' -l multiple -d 'Only show formulae with multiple versions installed'
__fish_brew_complete_arg 'list' -l pinned -d 'List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`'
__fish_brew_complete_arg 'list' -l quiet -d 'Make some output more quiet'
__fish_brew_complete_arg 'list' -l verbose -d 'Make some output more verbose'
__fish_brew_complete_arg 'list' -l versions -d 'Show the version number for installed formulae, or only the specified formulae if formula are provided'
__fish_brew_complete_arg 'list' -l 1 -d 'Force output to be one entry per line. This is the default when output is not to a terminal'
__fish_brew_complete_arg 'list' -l l -d 'List formulae and/or casks in long format. Has no effect when a formula or cask name is passed as an argument'
__fish_brew_complete_arg 'list' -l r -d 'Reverse the order of the formulae and/or casks sort to list the oldest entries first. Has no effect when a formula or cask name is passed as an argument'
__fish_brew_complete_arg 'list' -l t -d 'Sort formulae and/or casks by time modified, listing most recently modified first. Has no effect when a formula or cask name is passed as an argument'
__fish_brew_complete_arg 'list; and not __fish_seen_argument -l cask -l casks' -a '(__fish_brew_suggest_formulae_installed)'
__fish_brew_complete_arg 'list; and not __fish_seen_argument -l formula -l formulae' -a '(__fish_brew_suggest_casks_installed)'


__fish_brew_complete_cmd 'livecheck' 'Check for newer versions of formulae and/or casks from upstream'
__fish_brew_complete_arg 'livecheck' -l cask -d 'Only check casks'
__fish_brew_complete_arg 'livecheck' -l debug -d 'Display any debugging information'
__fish_brew_complete_arg 'livecheck' -l eval-all -d 'Evaluate all available formulae and casks, whether installed or not, to check them'
__fish_brew_complete_arg 'livecheck' -l extract-plist -d 'Include casks using the ExtractPlist livecheck strategy'
__fish_brew_complete_arg 'livecheck' -l formula -d 'Only check formulae'
__fish_brew_complete_arg 'livecheck' -l full-name -d 'Print formulae and casks with fully-qualified names'
__fish_brew_complete_arg 'livecheck' -l help -d 'Show this message'
__fish_brew_complete_arg 'livecheck' -l installed -d 'Check formulae and casks that are currently installed'
__fish_brew_complete_arg 'livecheck' -l json -d 'Output information in JSON format'
__fish_brew_complete_arg 'livecheck' -l newer-only -d 'Show the latest version only if it\'s newer than the formula/cask'
__fish_brew_complete_arg 'livecheck' -l no-extract-plist -d 'Exclude casks using the ExtractPlist livecheck strategy'
__fish_brew_complete_arg 'livecheck' -l quiet -d 'Suppress warnings, don\'t print a progress bar for JSON output'
__fish_brew_complete_arg 'livecheck' -l resources -d 'Also check resources for formulae'
__fish_brew_complete_arg 'livecheck' -l tap -d 'Check formulae and casks within the given tap, specified as user`/`repo'
Expand Down Expand Up @@ -1055,25 +1036,6 @@ __fish_brew_complete_arg 'log; and not __fish_seen_argument -l cask -l casks' -a
__fish_brew_complete_arg 'log; and not __fish_seen_argument -l formula -l formulae' -a '(__fish_brew_suggest_casks_all)'


__fish_brew_complete_cmd 'ls' 'List all installed formulae and casks'
__fish_brew_complete_arg 'ls' -l cask -d 'List only casks, or treat all named arguments as casks'
__fish_brew_complete_arg 'ls' -l debug -d 'Display any debugging information'
__fish_brew_complete_arg 'ls' -l formula -d 'List only formulae, or treat all named arguments as formulae'
__fish_brew_complete_arg 'ls' -l full-name -d 'Print formulae with fully-qualified names. Unless `--full-name`, `--versions` or `--pinned` are passed, other options (i.e. `-1`, `-l`, `-r` and `-t`) are passed to `ls`(1) which produces the actual output'
__fish_brew_complete_arg 'ls' -l help -d 'Show this message'
__fish_brew_complete_arg 'ls' -l multiple -d 'Only show formulae with multiple versions installed'
__fish_brew_complete_arg 'ls' -l pinned -d 'List only pinned formulae, or only the specified (pinned) formulae if formula are provided. See also `pin`, `unpin`'
__fish_brew_complete_arg 'ls' -l quiet -d 'Make some output more quiet'
__fish_brew_complete_arg 'ls' -l verbose -d 'Make some output more verbose'
__fish_brew_complete_arg 'ls' -l versions -d 'Show the version number for installed formulae, or only the specified formulae if formula are provided'
__fish_brew_complete_arg 'ls' -l 1 -d 'Force output to be one entry per line. This is the default when output is not to a terminal'
__fish_brew_complete_arg 'ls' -l l -d 'List formulae and/or casks in long format. Has no effect when a formula or cask name is passed as an argument'
__fish_brew_complete_arg 'ls' -l r -d 'Reverse the order of the formulae and/or casks sort to list the oldest entries first. Has no effect when a formula or cask name is passed as an argument'
__fish_brew_complete_arg 'ls' -l t -d 'Sort formulae and/or casks by time modified, listing most recently modified first. Has no effect when a formula or cask name is passed as an argument'
__fish_brew_complete_arg 'ls; and not __fish_seen_argument -l cask -l casks' -a '(__fish_brew_suggest_formulae_installed)'
__fish_brew_complete_arg 'ls; and not __fish_seen_argument -l formula -l formulae' -a '(__fish_brew_suggest_casks_installed)'


__fish_brew_complete_cmd 'migrate' 'Migrate renamed packages to new names, where formula are old names of packages'
__fish_brew_complete_arg 'migrate' -l cask -d 'Only migrate casks'
__fish_brew_complete_arg 'migrate' -l debug -d 'Display any debugging information'
Expand Down Expand Up @@ -1231,15 +1193,6 @@ __fish_brew_complete_arg 'pr-upload' -l verbose -d 'Make some output more verbos
__fish_brew_complete_arg 'pr-upload' -l warn-on-upload-failure -d 'Warn instead of raising an error if the bottle upload fails. Useful for repairing bottle uploads that previously failed'


__fish_brew_complete_cmd 'prof' 'Run Homebrew with a Ruby profiler'
__fish_brew_complete_arg 'prof' -l debug -d 'Display any debugging information'
__fish_brew_complete_arg 'prof' -l help -d 'Show this message'
__fish_brew_complete_arg 'prof' -l quiet -d 'Make some output more quiet'
__fish_brew_complete_arg 'prof' -l stackprof -d 'Use `stackprof` instead of `ruby-prof` (the default)'
__fish_brew_complete_arg 'prof' -l verbose -d 'Make some output more verbose'
__fish_brew_complete_arg 'prof' -a '(__fish_brew_suggest_commands)'


__fish_brew_complete_cmd 'pyenv-sync' 'Create symlinks for Homebrew\'s installed Python versions in `~/.pyenv/versions`'
__fish_brew_complete_arg 'pyenv-sync' -l debug -d 'Display any debugging information'
__fish_brew_complete_arg 'pyenv-sync' -l help -d 'Show this message'
Expand Down

0 comments on commit bf76e51

Please sign in to comment.