From 8e01227addd78731b3d64a9a49797e6005529c69 Mon Sep 17 00:00:00 2001 From: Eric Knibbe Date: Thu, 12 Oct 2023 07:58:25 -0400 Subject: [PATCH] cmd/deps: show deps for head spec with `--HEAD` Plus a few man page fixes --- Library/Homebrew/cmd/--cache.rb | 4 ++-- Library/Homebrew/cmd/deps.rb | 19 +++++++++++++++---- Library/Homebrew/cmd/fetch.rb | 4 ++-- Library/Homebrew/dev-cmd/test.rb | 2 +- completions/bash/brew | 1 + completions/fish/brew.fish | 15 ++++++++------- completions/zsh/_brew | 17 +++++++++-------- docs/Manpage.md | 16 +++++++++------- manpages/brew.1 | 18 +++++++++++------- 9 files changed, 58 insertions(+), 38 deletions(-) diff --git a/Library/Homebrew/cmd/--cache.rb b/Library/Homebrew/cmd/--cache.rb index 944bb72da2..050ac2a0b2 100644 --- a/Library/Homebrew/cmd/--cache.rb +++ b/Library/Homebrew/cmd/--cache.rb @@ -17,10 +17,10 @@ module Homebrew If is provided, display the file or directory used to cache . EOS flag "--os=", - description: "Show cache file for the given operating system." \ + description: "Show cache file for the given operating system. " \ "(Pass `all` to show cache files for all operating systems.)" flag "--arch=", - description: "Show cache file for the given CPU architecture." \ + description: "Show cache file for the given CPU architecture. " \ "(Pass `all` to show cache files for all architectures.)" switch "-s", "--build-from-source", description: "Show the cache file used when building from source." diff --git a/Library/Homebrew/cmd/deps.rb b/Library/Homebrew/cmd/deps.rb index 7d8cbd5829..dc138a9267 100644 --- a/Library/Homebrew/cmd/deps.rb +++ b/Library/Homebrew/cmd/deps.rb @@ -51,7 +51,7 @@ module Homebrew depends_on: "--graph", description: "Show text-based graph description in DOT format." 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." switch "--installed", description: "List dependencies for formulae that are currently installed. If is " \ @@ -62,9 +62,11 @@ module Homebrew description: "Evaluate all available formulae and casks, whether installed or not, to list " \ "their dependencies." 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 , 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", description: "Treat all named arguments as formulae." switch "--cask", "--casks", @@ -73,7 +75,6 @@ module Homebrew conflicts "--tree", "--graph" conflicts "--installed", "--missing" conflicts "--installed", "--eval-all" - conflicts "--installed", "--all" conflicts "--formula", "--cask" formula_options @@ -94,6 +95,7 @@ module Homebrew @use_runtime_dependencies = installed && recursive && !args.tree? && !args.graph? && + !args.HEAD? && !args.include_build? && !args.include_test? && !args.include_optional? && @@ -153,6 +155,7 @@ module Homebrew end 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? ? :| : :&)) 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) 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) + check_head_spec(dependents) if args.HEAD? dependents.each do |dependent| deps = deps_for_dependent(dependent, recursive: recursive, args: args) condense_requirements(deps, args: args) @@ -268,6 +278,7 @@ module Homebrew end def self.puts_deps_tree(dependents, args:, recursive: false) + check_head_spec(dependents) if args.HEAD? dependents.each do |d| puts d.full_name recursive_deps_tree(d, dep_stack: [], prefix: "", recursive: recursive, args: args) diff --git a/Library/Homebrew/cmd/fetch.rb b/Library/Homebrew/cmd/fetch.rb index 229a984ab0..f747bc5b21 100644 --- a/Library/Homebrew/cmd/fetch.rb +++ b/Library/Homebrew/cmd/fetch.rb @@ -19,10 +19,10 @@ module Homebrew and binaries for s. For files, also print SHA-256 checksums. EOS flag "--os=", - description: "Download for the given operating system." \ + description: "Download for the given operating system. " \ "(Pass `all` to download for all operating systems.)" flag "--arch=", - description: "Download for the given CPU architecture." \ + description: "Download for the given CPU architecture. " \ "(Pass `all` to download for all architectures.)" flag "--bottle-tag=", description: "Download a bottle for given tag." diff --git a/Library/Homebrew/dev-cmd/test.rb b/Library/Homebrew/dev-cmd/test.rb index b9b7004425..6a0d018848 100644 --- a/Library/Homebrew/dev-cmd/test.rb +++ b/Library/Homebrew/dev-cmd/test.rb @@ -22,7 +22,7 @@ module Homebrew switch "-f", "--force", description: "Test formulae even if they are unlinked." switch "--HEAD", - description: "Test the head version of a formula." + description: "Test the HEAD version of a formula." switch "--keep-tmp", description: "Retain the temporary files created for the test." switch "--retry", diff --git a/completions/bash/brew b/completions/bash/brew index 97364b8c04..bddbb67163 100644 --- a/completions/bash/brew +++ b/completions/bash/brew @@ -737,6 +737,7 @@ _brew_deps() { case "${cur}" in -*) __brewcomp " + --HEAD --annotate --cask --debug diff --git a/completions/fish/brew.fish b/completions/fish/brew.fish index 25851c55d4..67a255d7d0 100644 --- a/completions/fish/brew.fish +++ b/completions/fish/brew.fish @@ -192,7 +192,7 @@ end __fish_brew_complete_cmd '--cache' 'Display Homebrew\'s download cache' __fish_brew_complete_arg '--cache' -l HEAD -d 'Show the cache file used when building from HEAD' -__fish_brew_complete_arg '--cache' -l arch -d 'Show cache file for the given CPU architecture.(Pass `all` to show cache files for all architectures.)' +__fish_brew_complete_arg '--cache' -l arch -d 'Show cache file for the given CPU architecture. (Pass `all` to show cache files for all architectures.)' __fish_brew_complete_arg '--cache' -l bottle-tag -d 'Show the cache file used when pouring a bottle for the given tag' __fish_brew_complete_arg '--cache' -l build-from-source -d 'Show the cache file used when building from source' __fish_brew_complete_arg '--cache' -l cask -d 'Only show cache files for casks' @@ -200,7 +200,7 @@ __fish_brew_complete_arg '--cache' -l debug -d 'Display any debugging informatio __fish_brew_complete_arg '--cache' -l force-bottle -d 'Show the cache file used when pouring a bottle' __fish_brew_complete_arg '--cache' -l formula -d 'Only show cache files for formulae' __fish_brew_complete_arg '--cache' -l help -d 'Show this message' -__fish_brew_complete_arg '--cache' -l os -d 'Show cache file for the given operating system.(Pass `all` to show cache files for all operating systems.)' +__fish_brew_complete_arg '--cache' -l os -d 'Show cache file for the given operating system. (Pass `all` to show cache files for all operating systems.)' __fish_brew_complete_arg '--cache' -l quiet -d 'Make some output more quiet' __fish_brew_complete_arg '--cache' -l verbose -d 'Make some output more verbose' __fish_brew_complete_arg '--cache; and not __fish_seen_argument -l cask -l casks' -a '(__fish_brew_suggest_formulae_all)' @@ -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_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 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 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 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 full-name -d 'List dependencies by their full name' __fish_brew_complete_arg 'deps' -l graph -d 'Show dependencies as a directed graph' @@ -706,7 +707,7 @@ __fish_brew_complete_arg 'extract' -a '(__fish_brew_suggest_taps_installed)' __fish_brew_complete_cmd 'fetch' 'Download a bottle (if available) or source packages for formulae and binaries for casks' __fish_brew_complete_arg 'fetch' -l HEAD -d 'Fetch HEAD version instead of stable version' -__fish_brew_complete_arg 'fetch' -l arch -d 'Download for the given CPU architecture.(Pass `all` to download for all architectures.)' +__fish_brew_complete_arg 'fetch' -l arch -d 'Download for the given CPU architecture. (Pass `all` to download for all architectures.)' __fish_brew_complete_arg 'fetch' -l bottle-tag -d 'Download a bottle for given tag' __fish_brew_complete_arg 'fetch' -l build-bottle -d 'Download source packages (for eventual bottling) rather than a bottle' __fish_brew_complete_arg 'fetch' -l build-from-source -d 'Download source packages rather than a bottle' @@ -718,7 +719,7 @@ __fish_brew_complete_arg 'fetch' -l force-bottle -d 'Download a bottle if it exi __fish_brew_complete_arg 'fetch' -l formula -d 'Treat all named arguments as formulae' __fish_brew_complete_arg 'fetch' -l help -d 'Show this message' __fish_brew_complete_arg 'fetch' -l no-quarantine -d 'Disable/enable quarantining of downloads (default: enabled)' -__fish_brew_complete_arg 'fetch' -l os -d 'Download for the given operating system.(Pass `all` to download for all operating systems.)' +__fish_brew_complete_arg 'fetch' -l os -d 'Download for the given operating system. (Pass `all` to download for all operating systems.)' __fish_brew_complete_arg 'fetch' -l quarantine -d 'Disable/enable quarantining of downloads (default: enabled)' __fish_brew_complete_arg 'fetch' -l quiet -d 'Make some output more quiet' __fish_brew_complete_arg 'fetch' -l retry -d 'Retry if downloading fails or re-download if the checksum of a previously cached version no longer matches. Tries at most 5 times with exponential backoff' @@ -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_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 force -d 'Test formulae even if they are unlinked' __fish_brew_complete_arg 'test' -l help -d 'Show this message' diff --git a/completions/zsh/_brew b/completions/zsh/_brew index 658343b91a..b6aee53e4b 100644 --- a/completions/zsh/_brew +++ b/completions/zsh/_brew @@ -264,13 +264,13 @@ __brew_diagnostic_checks() { _brew___cache() { _arguments \ '(--build-from-source --force-bottle --bottle-tag --cask)--HEAD[Show the cache file used when building from HEAD]' \ - '(--bottle-tag)--arch[Show cache file for the given CPU architecture.(Pass `all` to show cache files for all architectures.)]' \ + '(--bottle-tag)--arch[Show cache file for the given CPU architecture. (Pass `all` to show cache files for all architectures.)]' \ '(--build-from-source --force-bottle --HEAD --cask --os --arch)--bottle-tag[Show the cache file used when pouring a bottle for the given tag]' \ '(--force-bottle --bottle-tag --HEAD --cask)--build-from-source[Show the cache file used when building from source]' \ '--debug[Display any debugging information]' \ '(--build-from-source --bottle-tag --HEAD --cask)--force-bottle[Show the cache file used when pouring a bottle]' \ '--help[Show this message]' \ - '(--bottle-tag)--os[Show cache file for the given operating system.(Pass `all` to show cache files for all operating systems.)]' \ + '(--bottle-tag)--os[Show cache file for the given operating system. (Pass `all` to show cache files for all operating systems.)]' \ '--quiet[Make some output more quiet]' \ '--verbose[Make some output more verbose]' \ - formula \ @@ -715,12 +715,13 @@ _brew_create() { # brew deps _brew_deps() { _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]' \ '--direct[Show only the direct dependencies declared in the formula]' \ '--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]' \ - '--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]' \ '(--tree)--graph[Show dependencies as a directed graph]' \ '--help[Show this message]' \ @@ -728,7 +729,7 @@ _brew_deps() { '--include-optional[Include `:optional` dependencies for formula]' \ '--include-requirements[Include requirements in addition to dependencies for formula]' \ '--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]' \ '--quiet[Make some output more quiet]' \ '--skip-recommended[Skip `:recommended` dependencies for formula]' \ @@ -890,7 +891,7 @@ _brew_extract() { _brew_fetch() { _arguments \ '(--cask)--HEAD[Fetch HEAD version instead of stable version]' \ - '(--bottle-tag)--arch[Download for the given CPU architecture.(Pass `all` to download for all architectures.)]' \ + '(--bottle-tag)--arch[Download for the given CPU architecture. (Pass `all` to download for all architectures.)]' \ '(--build-from-source --build-bottle --force-bottle --cask --os --arch)--bottle-tag[Download a bottle for given tag]' \ '(--build-from-source --force-bottle --bottle-tag --cask)--build-bottle[Download source packages (for eventual bottling) rather than a bottle]' \ '(--build-bottle --force-bottle --bottle-tag)--build-from-source[Download source packages rather than a bottle]' \ @@ -900,7 +901,7 @@ _brew_fetch() { '(--build-from-source --build-bottle --bottle-tag --cask)--force-bottle[Download a bottle if it exists for the current or newest version of macOS, even if it would not be used during installation]' \ '--help[Show this message]' \ '--no-quarantine[Disable/enable quarantining of downloads (default: enabled)]' \ - '(--bottle-tag)--os[Download for the given operating system.(Pass `all` to download for all operating systems.)]' \ + '(--bottle-tag)--os[Download for the given operating system. (Pass `all` to download for all operating systems.)]' \ '--quarantine[Disable/enable quarantining of downloads (default: enabled)]' \ '--quiet[Make some output more quiet]' \ '--retry[Retry if downloading fails or re-download if the checksum of a previously cached version no longer matches. Tries at most 5 times with exponential backoff]' \ @@ -1796,7 +1797,7 @@ _brew_tc() { # brew test _brew_test() { _arguments \ - '--HEAD[Test the head version of a formula]' \ + '--HEAD[Test the HEAD version of a formula]' \ '--debug[Display any debugging information]' \ '--force[Test formulae even if they are unlinked]' \ '--help[Show this message]' \ diff --git a/docs/Manpage.md b/docs/Manpage.md index 1242d61b4f..3d9e477965 100644 --- a/docs/Manpage.md +++ b/docs/Manpage.md @@ -173,7 +173,7 @@ dependencies if the installed versions are outdated. * `--dot`: Show text-based graph description in DOT format. * `--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`: List dependencies for formulae that are currently installed. If *`formula`* is specified, list only its dependencies that are currently installed. * `--missing`: @@ -181,7 +181,9 @@ dependencies if the installed versions are outdated. * `--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. + 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`: Treat all named arguments as formulae. * `--cask`: @@ -241,9 +243,9 @@ Download a bottle (if available) or source packages for *`formula`*e and binaries for *`cask`*s. For files, also print SHA-256 checksums. * `--os`: - Download for the given operating system.(Pass `all` to download for all operating systems.) + Download for the given operating system. (Pass `all` to download for all operating systems.) * `--arch`: - Download for the given CPU architecture.(Pass `all` to download for all architectures.) + Download for the given CPU architecture. (Pass `all` to download for all architectures.) * `--bottle-tag`: Download a bottle for given tag. * `--HEAD`: @@ -853,9 +855,9 @@ Display Homebrew's download cache. See also `HOMEBREW_CACHE`. If *`formula`* is provided, display the file or directory used to cache *`formula`*. * `--os`: - Show cache file for the given operating system.(Pass `all` to show cache files for all operating systems.) + Show cache file for the given operating system. (Pass `all` to show cache files for all operating systems.) * `--arch`: - Show cache file for the given CPU architecture.(Pass `all` to show cache files for all architectures.) + Show cache file for the given CPU architecture. (Pass `all` to show cache files for all architectures.) * `-s`, `--build-from-source`: Show the cache file used when building from source. * `--force-bottle`: @@ -1566,7 +1568,7 @@ user if something is wrong with the installed formula. * `-f`, `--force`: Test formulae even if they are unlinked. * `--HEAD`: - Test the head version of a formula. + Test the HEAD version of a formula. * `--keep-tmp`: Retain the temporary files created for the test. * `--retry`: diff --git a/manpages/brew.1 b/manpages/brew.1 index 89232d76b2..1c433fc6a7 100644 --- a/manpages/brew.1 +++ b/manpages/brew.1 @@ -213,7 +213,7 @@ Show text\-based graph description in DOT format\. . .TP \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 \fB\-\-installed\fR @@ -229,7 +229,11 @@ Evaluate all available formulae and casks, whether installed or not, to list the . .TP \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 \fB\-\-formula\fR @@ -299,11 +303,11 @@ Download a bottle (if available) or source packages for \fIformula\fRe and binar . .TP \fB\-\-os\fR -Download for the given operating system\.(Pass \fBall\fR to download for all operating systems\.) +Download for the given operating system\. (Pass \fBall\fR to download for all operating systems\.) . .TP \fB\-\-arch\fR -Download for the given CPU architecture\.(Pass \fBall\fR to download for all architectures\.) +Download for the given CPU architecture\. (Pass \fBall\fR to download for all architectures\.) . .TP \fB\-\-bottle\-tag\fR @@ -1197,11 +1201,11 @@ If \fIformula\fR is provided, display the file or directory used to cache \fIfor . .TP \fB\-\-os\fR -Show cache file for the given operating system\.(Pass \fBall\fR to show cache files for all operating systems\.) +Show cache file for the given operating system\. (Pass \fBall\fR to show cache files for all operating systems\.) . .TP \fB\-\-arch\fR -Show cache file for the given CPU architecture\.(Pass \fBall\fR to show cache files for all architectures\.) +Show cache file for the given CPU architecture\. (Pass \fBall\fR to show cache files for all architectures\.) . .TP \fB\-s\fR, \fB\-\-build\-from\-source\fR @@ -2239,7 +2243,7 @@ Test formulae even if they are unlinked\. . .TP \fB\-\-HEAD\fR -Test the head version of a formula\. +Test the HEAD version of a formula\. . .TP \fB\-\-keep\-tmp\fR