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

livecheck: add --extract-plist #16759

Merged
merged 1 commit into from Mar 21, 2024
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 4 additions & 0 deletions Library/Homebrew/dev-cmd/livecheck.rb
Expand Up @@ -38,10 +38,13 @@ def livecheck_args
description: "Only check formulae."
switch "--cask", "--casks",
description: "Only check casks."
switch "--extract-plist",
description: "Include casks using the ExtractPlist livecheck strategy."

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

named_args [:formula, :cask], without_api: true
end
Expand Down Expand Up @@ -125,6 +128,7 @@ 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?,
Expand Down
22 changes: 19 additions & 3 deletions Library/Homebrew/livecheck/livecheck.rb
Expand Up @@ -167,6 +167,7 @@
check_resources: T::Boolean,
json: T::Boolean,
newer_only: T::Boolean,
extract_plist: T::Boolean,
debug: T::Boolean,
quiet: T::Boolean,
verbose: T::Boolean,
Expand All @@ -175,7 +176,7 @@
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
extract_plist: false, debug: false, quiet: false, verbose: false
)
load_other_tap_strategies(formulae_and_casks_to_check)

Expand All @@ -200,9 +201,9 @@

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
formulae_and_casks_total = formulae_and_casks_to_check.count

if json && !quiet && $stderr.tty?
Tty.with($stderr) do |stderr|
stderr.puts Formatter.headline("Running checks", color: :blue)
end
Expand All @@ -217,6 +218,9 @@
)
end

# If only one formula/cask is being checked, we enable extract-plist
extract_plist = true if formulae_and_casks_total == 1
MikeMcQuaid marked this conversation as resolved.
Show resolved Hide resolved

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 @@ -237,6 +241,18 @@
puts
end

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

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

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/livecheck/livecheck.rb#L246

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

SkipConditions.print_skip_information(skip_info) if !newer_only && !quiet
next

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

View check run for this annotation

Codecov / codecov/patch

Library/Homebrew/livecheck/livecheck.rb#L253

Added line #L253 was not covered by tests
end

# Check skip conditions for a referenced formula/cask
if referenced_formula_or_cask
skip_info = SkipConditions.referenced_skip_information(
Expand Down
2 changes: 2 additions & 0 deletions completions/bash/brew
Expand Up @@ -1330,6 +1330,7 @@ _brew_lc() {
--cask
--debug
--eval-all
--extract-plist
--formula
--full-name
--help
Expand Down Expand Up @@ -1445,6 +1446,7 @@ _brew_livecheck() {
--cask
--debug
--eval-all
--extract-plist
--formula
--full-name
--help
Expand Down
2 changes: 2 additions & 0 deletions completions/fish/brew.fish
Expand Up @@ -941,6 +941,7 @@ __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'
Expand Down Expand Up @@ -1011,6 +1012,7 @@ __fish_brew_complete_cmd 'livecheck' 'Check for newer versions of formulae and/o
__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'
Expand Down
6 changes: 4 additions & 2 deletions completions/zsh/_brew
Expand Up @@ -1168,6 +1168,7 @@ _brew_lc() {
_arguments \
'(--json)--debug[Display any debugging information]' \
'(--tap --installed)--eval-all[Evaluate all available formulae and casks, whether installed or not, to check them]' \
'(--formula)--extract-plist[Include casks using the ExtractPlist livecheck strategy]' \
'--full-name[Print formulae and casks with fully-qualified names]' \
'--help[Show this message]' \
'(--tap --eval-all)--installed[Check formulae and casks that are currently installed]' \
Expand All @@ -1178,7 +1179,7 @@ _brew_lc() {
'(--eval-all --installed)--tap[Check formulae and casks within the given tap, specified as user`/`repo]' \
'--verbose[Make some output more verbose]' \
- formula \
'(--cask)--formula[Only check formulae]' \
'(--cask --extract-plist)--formula[Only check formulae]' \
'*::formula:__brew_formulae' \
- cask \
'(--formula)--cask[Only check casks]' \
Expand Down Expand Up @@ -1254,6 +1255,7 @@ _brew_livecheck() {
_arguments \
'(--json)--debug[Display any debugging information]' \
'(--tap --installed)--eval-all[Evaluate all available formulae and casks, whether installed or not, to check them]' \
'(--formula)--extract-plist[Include casks using the ExtractPlist livecheck strategy]' \
'--full-name[Print formulae and casks with fully-qualified names]' \
'--help[Show this message]' \
'(--tap --eval-all)--installed[Check formulae and casks that are currently installed]' \
Expand All @@ -1264,7 +1266,7 @@ _brew_livecheck() {
'(--eval-all --installed)--tap[Check formulae and casks within the given tap, specified as user`/`repo]' \
'--verbose[Make some output more verbose]' \
- formula \
'(--cask)--formula[Only check formulae]' \
'(--cask --extract-plist)--formula[Only check formulae]' \
'*::formula:__brew_formulae' \
- cask \
'(--formula)--cask[Only check casks]' \
Expand Down
4 changes: 4 additions & 0 deletions docs/Manpage.md
Expand Up @@ -2288,6 +2288,10 @@ from `HOMEBREW_LIVECHECK_WATCHLIST` or `~/.homebrew/livecheck_watchlist.txt`.

: Only check casks.

`--extract-plist`

: Include casks using the ExtractPlist livecheck strategy.

### `pr-automerge` \[*`options`*\]

Find pull requests that can be automatically merged using `brew pr-publish`.
Expand Down
3 changes: 3 additions & 0 deletions manpages/brew.1
Expand Up @@ -1453,6 +1453,9 @@ Only check formulae\.
.TP
\fB\-\-cask\fP
Only check casks\.
.TP
\fB\-\-extract\-plist\fP
Include casks using the ExtractPlist livecheck strategy\.
.SS "\fBpr\-automerge\fP \fR[\fIoptions\fP]"
Find pull requests that can be automatically merged using \fBbrew pr\-publish\fP\&\.
.TP
Expand Down