-
-
Notifications
You must be signed in to change notification settings - Fork 10k
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
cask/info: send missing args after removing openstruct #18917
Conversation
This seems like it was a bug before the recent change to remove OpenStruct from `Homebrew::CLI::Args` but it was failing silently before. Now we pass the args to the `Cask::Info.info` method so that when they eventually reach the `Utils::Analytics.output_analytics` method they are present as expected. Example error fragment: ```console $ set -e HOMEBREW_NO_ANALYTICS $ brew info iterm2 --cask --verbose ==> iterm2: 3.5.10 (auto_updates) https://iterm2.com/ Installed /usr/local/Caskroom/iterm2/3.5.4 (91.7MB) From: https://github.com/Homebrew/homebrew-cask/blob/HEAD/Casks/i/iterm2.rb ==> Name iTerm2 ==> Description Terminal emulator as alternative to Apple's Terminal app ==> Artifacts iTerm.app (App) Error: undefined method `analytics?' for an instance of Homebrew::CLI::Args /usr/local/Homebrew/Library/Homebrew/utils/analytics.rb:248:in `output_analytics' /usr/local/Homebrew/Library/Homebrew/utils/analytics.rb:342:in `cask_output' /usr/local/Homebrew/Library/Homebrew/cask/info.rb:39:in `info' ```
::Utils::Analytics.cask_output(cask, args: Homebrew::CLI::Args.new) | ||
::Utils::Analytics.cask_output(cask, args:) |
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 believe this was an existing bug that only came to light because of recent changes. It seems like by creating a new instance of the CLI args here that args.analytics?
would always be falsey later on which doesn't seem to be the desired behavior. Now when the --analytics
flag is set it will get passed to Utils::Analytics.cask_output
the same way it already gets passed to Utils::Analytics.formula_output
.
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.
Nice work! We might want to add some guardrails around where/how Args
can be instantiated 🤔
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.
IMO it's probably not necessary unless it's really simple to implement since I doubt that we'll ever run into the same problem again.
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.
Thanks @apainintheneck!
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?This should fix #18915 and is an attempt to fix forward so we don't have to rollback #18847 since this seems like a minor issue.
This seems like it was a bug before the recent change to remove OpenStruct from
Homebrew::CLI::Args
but it was failing silently before. Now we pass the args to theCask::Info.info
method so that when they eventually reach theUtils::Analytics.output_analytics
method they are present as expected.Note that this error requires
HOMEBREW_NO_ANALYTICS
to not be set and--verbose
to be passed along withbrew info CASK
.Example error fragment:
Expected output: