cmd/deps: show deps for head spec with --HEAD

Plus a few man page fixes
This commit is contained in:
Eric Knibbe 2023-10-12 07:58:25 -04:00
parent d3fd36da48
commit 8e01227add
No known key found for this signature in database
GPG Key ID: 179D9CDDDB814168
9 changed files with 58 additions and 38 deletions

View File

@ -51,7 +51,7 @@ module Homebrew
depends_on: "--graph", depends_on: "--graph",
description: "Show text-based graph description in DOT format." description: "Show text-based graph description in DOT format."
switch "--annotate", switch "--annotate",
description: "Mark any build, test, optional, or recommended dependencies as " \ description: "Mark any build, test, implicit, optional, or recommended dependencies as " \
"such in the output." "such in the output."
switch "--installed", switch "--installed",
description: "List dependencies for formulae that are currently installed. If <formula> is " \ description: "List dependencies for formulae that are currently installed. If <formula> is " \
@ -62,9 +62,11 @@ module Homebrew
description: "Evaluate all available formulae and casks, whether installed or not, to list " \ description: "Evaluate all available formulae and casks, whether installed or not, to list " \
"their dependencies." "their dependencies."
switch "--for-each", switch "--for-each",
description: "Switch into the mode used by the `--all` option, but only list dependencies " \ description: "Switch into the mode used by the `--eval-all` option, but only list dependencies " \
"for each provided <formula>, one formula per line. This is used for " \ "for each provided <formula>, one formula per line. This is used for " \
"debugging the `--installed`/`--all` display mode." "debugging the `--installed`/`--eval-all` display mode."
switch "--HEAD",
description: "Show dependencies for HEAD version instead of stable version."
switch "--formula", "--formulae", switch "--formula", "--formulae",
description: "Treat all named arguments as formulae." description: "Treat all named arguments as formulae."
switch "--cask", "--casks", switch "--cask", "--casks",
@ -73,7 +75,6 @@ module Homebrew
conflicts "--tree", "--graph" conflicts "--tree", "--graph"
conflicts "--installed", "--missing" conflicts "--installed", "--missing"
conflicts "--installed", "--eval-all" conflicts "--installed", "--eval-all"
conflicts "--installed", "--all"
conflicts "--formula", "--cask" conflicts "--formula", "--cask"
formula_options formula_options
@ -94,6 +95,7 @@ module Homebrew
@use_runtime_dependencies = installed && recursive && @use_runtime_dependencies = installed && recursive &&
!args.tree? && !args.tree? &&
!args.graph? && !args.graph? &&
!args.HEAD? &&
!args.include_build? && !args.include_build? &&
!args.include_test? && !args.include_test? &&
!args.include_optional? && !args.include_optional? &&
@ -153,6 +155,7 @@ module Homebrew
end end
dependents = dependents(args.named.to_formulae_and_casks) dependents = dependents(args.named.to_formulae_and_casks)
check_head_spec(dependents) if args.HEAD?
all_deps = deps_for_dependents(dependents, recursive: recursive, args: args, &(args.union? ? :| : :&)) all_deps = deps_for_dependents(dependents, recursive: recursive, args: args, &(args.union? ? :| : :&))
condense_requirements(all_deps, args: args) condense_requirements(all_deps, args: args)
@ -217,7 +220,14 @@ module Homebrew
dependents.map { |d| deps_for_dependent(d, recursive: recursive, args: args) }.reduce(&block) dependents.map { |d| deps_for_dependent(d, recursive: recursive, args: args) }.reduce(&block)
end end
def self.check_head_spec(dependents)
headless = dependents.select { |d| d.is_a?(Formula) && d.active_spec_sym != :head }
.to_sentence two_words_connector: " or ", last_word_connector: " or "
opoo "No head spec for #{headless}, using stable spec instead" unless headless.empty?
end
def self.puts_deps(dependents, args:, recursive: false) def self.puts_deps(dependents, args:, recursive: false)
check_head_spec(dependents) if args.HEAD?
dependents.each do |dependent| dependents.each do |dependent|
deps = deps_for_dependent(dependent, recursive: recursive, args: args) deps = deps_for_dependent(dependent, recursive: recursive, args: args)
condense_requirements(deps, args: args) condense_requirements(deps, args: args)
@ -268,6 +278,7 @@ module Homebrew
end end
def self.puts_deps_tree(dependents, args:, recursive: false) def self.puts_deps_tree(dependents, args:, recursive: false)
check_head_spec(dependents) if args.HEAD?
dependents.each do |d| dependents.each do |d|
puts d.full_name puts d.full_name
recursive_deps_tree(d, dep_stack: [], prefix: "", recursive: recursive, args: args) recursive_deps_tree(d, dep_stack: [], prefix: "", recursive: recursive, args: args)

View File

@ -22,7 +22,7 @@ module Homebrew
switch "-f", "--force", switch "-f", "--force",
description: "Test formulae even if they are unlinked." description: "Test formulae even if they are unlinked."
switch "--HEAD", switch "--HEAD",
description: "Test the head version of a formula." description: "Test the HEAD version of a formula."
switch "--keep-tmp", switch "--keep-tmp",
description: "Retain the temporary files created for the test." description: "Retain the temporary files created for the test."
switch "--retry", switch "--retry",

View File

@ -737,6 +737,7 @@ _brew_deps() {
case "${cur}" in case "${cur}" in
-*) -*)
__brewcomp " __brewcomp "
--HEAD
--annotate --annotate
--cask --cask
--debug --debug

View File

@ -565,13 +565,14 @@ __fish_brew_complete_arg 'create' -l verbose -d 'Make some output more verbose'
__fish_brew_complete_cmd 'deps' 'Show dependencies for formula' __fish_brew_complete_cmd 'deps' 'Show dependencies for formula'
__fish_brew_complete_arg 'deps' -l annotate -d 'Mark any build, test, optional, or recommended dependencies as such in the output' __fish_brew_complete_arg 'deps' -l HEAD -d 'Show dependencies for HEAD version instead of stable version'
__fish_brew_complete_arg 'deps' -l annotate -d 'Mark any build, test, implicit, optional, or recommended dependencies as such in the output'
__fish_brew_complete_arg 'deps' -l cask -d 'Treat all named arguments as casks' __fish_brew_complete_arg 'deps' -l cask -d 'Treat all named arguments as casks'
__fish_brew_complete_arg 'deps' -l debug -d 'Display any debugging information' __fish_brew_complete_arg 'deps' -l debug -d 'Display any debugging information'
__fish_brew_complete_arg 'deps' -l direct -d 'Show only the direct dependencies declared in the formula' __fish_brew_complete_arg 'deps' -l direct -d 'Show only the direct dependencies declared in the formula'
__fish_brew_complete_arg 'deps' -l dot -d 'Show text-based graph description in DOT format' __fish_brew_complete_arg 'deps' -l dot -d 'Show text-based graph description in DOT format'
__fish_brew_complete_arg 'deps' -l eval-all -d 'Evaluate all available formulae and casks, whether installed or not, to list their dependencies' __fish_brew_complete_arg 'deps' -l eval-all -d 'Evaluate all available formulae and casks, whether installed or not, to list their dependencies'
__fish_brew_complete_arg 'deps' -l for-each -d 'Switch into the mode used by the `--all` option, but only list dependencies for each provided formula, one formula per line. This is used for debugging the `--installed`/`--all` display mode' __fish_brew_complete_arg 'deps' -l for-each -d 'Switch into the mode used by the `--eval-all` option, but only list dependencies for each provided formula, one formula per line. This is used for debugging the `--installed`/`--eval-all` display mode'
__fish_brew_complete_arg 'deps' -l formula -d 'Treat all named arguments as formulae' __fish_brew_complete_arg 'deps' -l formula -d 'Treat all named arguments as formulae'
__fish_brew_complete_arg 'deps' -l full-name -d 'List dependencies by their full name' __fish_brew_complete_arg 'deps' -l full-name -d 'List dependencies by their full name'
__fish_brew_complete_arg 'deps' -l graph -d 'Show dependencies as a directed graph' __fish_brew_complete_arg 'deps' -l graph -d 'Show dependencies as a directed graph'
@ -1454,7 +1455,7 @@ __fish_brew_complete_arg 'tc' -l verbose -d 'Make some output more verbose'
__fish_brew_complete_cmd 'test' 'Run the test method provided by an installed formula' __fish_brew_complete_cmd 'test' 'Run the test method provided by an installed formula'
__fish_brew_complete_arg 'test' -l HEAD -d 'Test the head version of a formula' __fish_brew_complete_arg 'test' -l HEAD -d 'Test the HEAD version of a formula'
__fish_brew_complete_arg 'test' -l debug -d 'Display any debugging information' __fish_brew_complete_arg 'test' -l debug -d 'Display any debugging information'
__fish_brew_complete_arg 'test' -l force -d 'Test formulae even if they are unlinked' __fish_brew_complete_arg 'test' -l force -d 'Test formulae even if they are unlinked'
__fish_brew_complete_arg 'test' -l help -d 'Show this message' __fish_brew_complete_arg 'test' -l help -d 'Show this message'

View File

@ -715,12 +715,13 @@ _brew_create() {
# brew deps # brew deps
_brew_deps() { _brew_deps() {
_arguments \ _arguments \
'--annotate[Mark any build, test, optional, or recommended dependencies as such in the output]' \ '--HEAD[Show dependencies for HEAD version instead of stable version]' \
'--annotate[Mark any build, test, implicit, optional, or recommended dependencies as such in the output]' \
'--debug[Display any debugging information]' \ '--debug[Display any debugging information]' \
'--direct[Show only the direct dependencies declared in the formula]' \ '--direct[Show only the direct dependencies declared in the formula]' \
'--dot[Show text-based graph description in DOT format]' \ '--dot[Show text-based graph description in DOT format]' \
'(--installed)--eval-all[Evaluate all available formulae and casks, whether installed or not, to list their dependencies]' \ '(--installed)--eval-all[Evaluate all available formulae and casks, whether installed or not, to list their dependencies]' \
'--for-each[Switch into the mode used by the `--all` option, but only list dependencies for each provided formula, one formula per line. This is used for debugging the `--installed`/`--all` display mode]' \ '--for-each[Switch into the mode used by the `--eval-all` option, but only list dependencies for each provided formula, one formula per line. This is used for debugging the `--installed`/`--eval-all` display mode]' \
'--full-name[List dependencies by their full name]' \ '--full-name[List dependencies by their full name]' \
'(--tree)--graph[Show dependencies as a directed graph]' \ '(--tree)--graph[Show dependencies as a directed graph]' \
'--help[Show this message]' \ '--help[Show this message]' \
@ -728,7 +729,7 @@ _brew_deps() {
'--include-optional[Include `:optional` dependencies for formula]' \ '--include-optional[Include `:optional` dependencies for formula]' \
'--include-requirements[Include requirements in addition to dependencies for formula]' \ '--include-requirements[Include requirements in addition to dependencies for formula]' \
'--include-test[Include `:test` dependencies for formula (non-recursive)]' \ '--include-test[Include `:test` dependencies for formula (non-recursive)]' \
'(--missing --eval-all --all)--installed[List dependencies for formulae that are currently installed. If formula is specified, list only its dependencies that are currently installed]' \ '(--missing --eval-all)--installed[List dependencies for formulae that are currently installed. If formula is specified, list only its dependencies that are currently installed]' \
'(--installed)--missing[Show only missing dependencies]' \ '(--installed)--missing[Show only missing dependencies]' \
'--quiet[Make some output more quiet]' \ '--quiet[Make some output more quiet]' \
'--skip-recommended[Skip `:recommended` dependencies for formula]' \ '--skip-recommended[Skip `:recommended` dependencies for formula]' \
@ -1796,7 +1797,7 @@ _brew_tc() {
# brew test # brew test
_brew_test() { _brew_test() {
_arguments \ _arguments \
'--HEAD[Test the head version of a formula]' \ '--HEAD[Test the HEAD version of a formula]' \
'--debug[Display any debugging information]' \ '--debug[Display any debugging information]' \
'--force[Test formulae even if they are unlinked]' \ '--force[Test formulae even if they are unlinked]' \
'--help[Show this message]' \ '--help[Show this message]' \

View File

@ -173,7 +173,7 @@ dependencies if the installed versions are outdated.
* `--dot`: * `--dot`:
Show text-based graph description in DOT format. Show text-based graph description in DOT format.
* `--annotate`: * `--annotate`:
Mark any build, test, optional, or recommended dependencies as such in the output. Mark any build, test, implicit, optional, or recommended dependencies as such in the output.
* `--installed`: * `--installed`:
List dependencies for formulae that are currently installed. If *`formula`* is specified, list only its dependencies that are currently installed. List dependencies for formulae that are currently installed. If *`formula`* is specified, list only its dependencies that are currently installed.
* `--missing`: * `--missing`:
@ -181,7 +181,9 @@ dependencies if the installed versions are outdated.
* `--eval-all`: * `--eval-all`:
Evaluate all available formulae and casks, whether installed or not, to list their dependencies. Evaluate all available formulae and casks, whether installed or not, to list their dependencies.
* `--for-each`: * `--for-each`:
Switch into the mode used by the `--all` option, but only list dependencies for each provided *`formula`*, one formula per line. This is used for debugging the `--installed`/`--all` display mode. Switch into the mode used by the `--eval-all` option, but only list dependencies for each provided *`formula`*, one formula per line. This is used for debugging the `--installed`/`--eval-all` display mode.
* `--HEAD`:
Show dependencies for HEAD version instead of stable version.
* `--formula`: * `--formula`:
Treat all named arguments as formulae. Treat all named arguments as formulae.
* `--cask`: * `--cask`:
@ -1566,7 +1568,7 @@ user if something is wrong with the installed formula.
* `-f`, `--force`: * `-f`, `--force`:
Test formulae even if they are unlinked. Test formulae even if they are unlinked.
* `--HEAD`: * `--HEAD`:
Test the head version of a formula. Test the HEAD version of a formula.
* `--keep-tmp`: * `--keep-tmp`:
Retain the temporary files created for the test. Retain the temporary files created for the test.
* `--retry`: * `--retry`:

View File

@ -213,7 +213,7 @@ Show text\-based graph description in DOT format\.
. .
.TP .TP
\fB\-\-annotate\fR \fB\-\-annotate\fR
Mark any build, test, optional, or recommended dependencies as such in the output\. Mark any build, test, implicit, optional, or recommended dependencies as such in the output\.
. .
.TP .TP
\fB\-\-installed\fR \fB\-\-installed\fR
@ -229,7 +229,11 @@ Evaluate all available formulae and casks, whether installed or not, to list the
. .
.TP .TP
\fB\-\-for\-each\fR \fB\-\-for\-each\fR
Switch into the mode used by the \fB\-\-all\fR option, but only list dependencies for each provided \fIformula\fR, one formula per line\. This is used for debugging the \fB\-\-installed\fR/\fB\-\-all\fR display mode\. Switch into the mode used by the \fB\-\-eval\-all\fR option, but only list dependencies for each provided \fIformula\fR, one formula per line\. This is used for debugging the \fB\-\-installed\fR/\fB\-\-eval\-all\fR display mode\.
.
.TP
\fB\-\-HEAD\fR
Show dependencies for HEAD version instead of stable version\.
. .
.TP .TP
\fB\-\-formula\fR \fB\-\-formula\fR
@ -2239,7 +2243,7 @@ Test formulae even if they are unlinked\.
. .
.TP .TP
\fB\-\-HEAD\fR \fB\-\-HEAD\fR
Test the head version of a formula\. Test the HEAD version of a formula\.
. .
.TP .TP
\fB\-\-keep\-tmp\fR \fB\-\-keep\-tmp\fR