-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
brew deps: add --include-requirements, plus some fixes #2996
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
brew deps: add --include-requirements, plus some fixes #2996
Conversation
|
Thanks for this PR @apjanke! It seems to work as expected in my testing.
It would be good if this were fixed before this goes in. (Also, it would be neat if --tree respected --1.) |
|
Added I see how to implement cycle detection to avoid the stack overflow. I'll add it. The |
|
Added circular-dependency detection. This fixes the stack overflow error. Now and |
A generic |
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Some style pedantry (some of which isn't your fault) but: nice work!
Library/Homebrew/cmd/deps.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Feels weird to use class variables for some of ARGV and not others. I'd lean on the side of never using them.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, I tried writing this to use function parameters for everything, and it got pretty hard to ready. Maybe it should fall back to using ARGV.include? everywhere? Or a single class instance variable for all the options? My impression is we're trying to move away from scattering global ARGV references everywhere.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it should fall back to using ARGV.include? everywhere?
Yeh, I agree.
My impression is we're trying to move away from scattering global ARGV references everywhere.
I think broadly but at this point it's probably reliant on having a decent Command DSL first.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated it to use direct ARGV references everywhere, and removed the class instance variables.
Library/Homebrew/cmd/deps.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
deps.map do |dep|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Library/Homebrew/cmd/deps.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
def dep_display_name(dep)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Library/Homebrew/cmd/deps.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we figure out a better name than chr here? line, maybe?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
how about tree_lines, to distinguish the graphical lines of the tree structure from a "line" of text?
Library/Homebrew/cmd/deps.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
puts "#{prefix}#{display_s}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
Library/Homebrew/cmd/deps.rb
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
prefix_extension = if i == max
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
|
Addressed most of the style pedantry, except for the use of class instance variables. Not sure what the right fix to do there is; using function parameters makes the code look pretty gross IMHO. I think class instance variables should be okay in the case of commands, since the modules are only loaded one per process, used once, and then the process ends. Deferring to the judgment of other maintainers here though. |
|
And, thanks! |
|
Updated the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Once brew style passes 👍
|
Arg! |
MikeMcQuaid
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good ![]()
|
Merged. Thanks for the feedback! |
I just tried |
brew testswith your changes locally?Adds a
--include-requirementsoption tobrew deps, to display all requirements, including ones without a default formula. Ones with a default formula are displayed as a requirement, with the default formula noted in parentheses. Per a suggestion by @ilovezfs.Mostly useful in conjunction with
--tree. This helps hunt down where a deeply-nested requirement is coming from. For example,octavehas an indirect dependency on:x11, but it has so many dependencies it's hard to tell where they're coming from. Or it lets you determine where the MinimumMacOS requirement formytopis coming from.Also fixes a bug in
--treewhere the dependencies of a Requirement's default formula were not recursed into.Also fixes a bug where the
--treemode ignored the--include-optional,--include-build, and--skip-recommendedfilters, instead always displaying build and recommended dependencies, and never optionals.Also adds an
--annotateoption to the--treemode, marking up optional, recommended, and build dependencies as such in the display.Also adds an undocumented
--for-eachswitch to help debug the--all/--installeddisplay mode, which couldn't previously be gotten to for a list of specified formulae.Before:
After:
Removing the colon before the default formula when not doing
--include-requirementsmakes the--treeoutput more consistent with the non-tree output.Note that if you include all of
--tree --include-optional --include-build --include-requirementson large formulae (likebrew deps octave --tree --include-optional --include-build --include-requirements), you can get a stack overflow error. I suspect this is because there's a circular dependency in the formula definitions somewhere. This could be worked around by using a stack to detect circular dependencies inside the code here, but I haven't put it in yet.Test failure
I'm getting this failure when I run
brew testslocally, but it's also happening for me onmaster. Don't think it's introduced by this PR.