Skip to content

Commit

Permalink
Merge pull request #16106 from EricFromCanada/cmd-deps-head
Browse files Browse the repository at this point in the history
cmd/deps: show deps for head spec with `--HEAD`
  • Loading branch information
MikeMcQuaid authored Oct 13, 2023
2 parents d3fd36d + 8e01227 commit b085889
Show file tree
Hide file tree
Showing 9 changed files with 58 additions and 38 deletions.
4 changes: 2 additions & 2 deletions Library/Homebrew/cmd/--cache.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ def self.__cache_args
If <formula> is provided, display the file or directory used to cache <formula>.
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."
Expand Down
19 changes: 15 additions & 4 deletions Library/Homebrew/cmd/deps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ def self.deps_args
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 <formula> is " \
Expand All @@ -62,9 +62,11 @@ def self.deps_args
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 <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",
description: "Treat all named arguments as formulae."
switch "--cask", "--casks",
Expand All @@ -73,7 +75,6 @@ def self.deps_args
conflicts "--tree", "--graph"
conflicts "--installed", "--missing"
conflicts "--installed", "--eval-all"
conflicts "--installed", "--all"
conflicts "--formula", "--cask"
formula_options

Expand All @@ -94,6 +95,7 @@ def self.deps
@use_runtime_dependencies = installed && recursive &&
!args.tree? &&
!args.graph? &&
!args.HEAD? &&
!args.include_build? &&
!args.include_test? &&
!args.include_optional? &&
Expand Down Expand Up @@ -153,6 +155,7 @@ def self.deps
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)
Expand Down Expand Up @@ -217,7 +220,14 @@ def self.deps_for_dependents(dependents, args:, recursive: false, &block)
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)
Expand Down Expand Up @@ -268,6 +278,7 @@ def self.graph_deps(formula, dep_graph:, recursive:, args:)
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)
Expand Down
4 changes: 2 additions & 2 deletions Library/Homebrew/cmd/fetch.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ def self.fetch_args
and binaries for <cask>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."
Expand Down
2 changes: 1 addition & 1 deletion Library/Homebrew/dev-cmd/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ def test_args
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",
Expand Down
1 change: 1 addition & 0 deletions completions/bash/brew
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,7 @@ _brew_deps() {
case "${cur}" in
-*)
__brewcomp "
--HEAD
--annotate
--cask
--debug
Expand Down
15 changes: 8 additions & 7 deletions completions/fish/brew.fish
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ 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'
__fish_brew_complete_arg '--cache' -l debug -d 'Display any debugging information'
__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)'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand All @@ -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'
Expand Down Expand Up @@ -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'
Expand Down
17 changes: 9 additions & 8 deletions completions/zsh/_brew
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down Expand Up @@ -715,20 +715,21 @@ _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]' \
'--include-build[Include `:build` dependencies for formula]' \
'--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]' \
Expand Down Expand Up @@ -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]' \
Expand All @@ -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]' \
Expand Down Expand Up @@ -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]' \
Expand Down
16 changes: 9 additions & 7 deletions docs/Manpage.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,15 +173,17 @@ 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`:
Show only missing dependencies.
* `--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`:
Expand Down Expand Up @@ -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`:
Expand Down Expand Up @@ -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`:
Expand Down Expand Up @@ -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`:
Expand Down
Loading

0 comments on commit b085889

Please sign in to comment.