-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
Add URL fallbacks for deprecated formula and cask checks #21198
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
base: main
Are you sure you want to change the base?
Conversation
ec3f2c7 to
9f91943
Compare
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.
Pull request overview
This PR adds URL fallbacks to deprecated/disabled formula and cask diagnostics to help users investigate why packages are deprecated without needing to run brew info separately. The URLs are displayed inline using a prioritized fallback chain.
Key changes:
- Added
formula_tap_urlandcask_tap_urlhelper methods to construct GitHub URLs for formula/cask files - Modified
check_deprecated_disabledandcheck_cask_deprecated_disabledto include URLs in their output - Added comprehensive test coverage for the new helper methods and URL fallback logic
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| Library/Homebrew/diagnostic.rb | Adds URL fallback logic to deprecated/disabled checks with helper methods formula_tap_url and cask_tap_url |
| Library/Homebrew/test/diagnostic_checks_spec.rb | Adds comprehensive test coverage for the new URL helper methods and fallback behavior |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Formulas `homepage` → `head.url (git repo)` → `tap file URL` Casks `homepage` → `tap file URL`
9f91943 to
5ad2ae7
Compare
@seivan Let's step back a bit here: what problem are you trying to solve here? What's the existing output? Why don't you like that? What's the new output? What problems are solved with it? Thanks! |
Access to information shouldn't take multiple steps.
Because it doesn't tell me why or where I can find more information or alternatives without doing a
@MikeMcQuaid It tells me what to lookup in case I want replacements or find a reason why or other work arounds. |
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.
All official formulae and casks have homepages so can simplify by skipping the fallbacks. Can remove any tests failing after this.
| url = f.homepage.presence || f.head&.url.presence || formula_tap_url(f) | ||
| url ? "#{f.full_name} (#{Formatter.url(url)})" : f.full_name |
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.
| url = f.homepage.presence || f.head&.url.presence || formula_tap_url(f) | |
| url ? "#{f.full_name} (#{Formatter.url(url)})" : f.full_name | |
| if (homepage = f.homepage.presence) | |
| "#{f.full_name} (#{Formatter.url(homepage)})" | |
| else | |
| f.full_name | |
| end |
| sig { params(formula: Formula).returns(T.nilable(String)) } | ||
| def formula_tap_url(formula) | ||
| tap = formula.tap | ||
| return if tap.blank? || tap.remote.blank? | ||
|
|
||
| path = formula.path.relative_path_from(tap.path) | ||
| "#{tap.remote}/blob/HEAD/#{path}" | ||
| end | ||
|
|
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.
| sig { params(formula: Formula).returns(T.nilable(String)) } | |
| def formula_tap_url(formula) | |
| tap = formula.tap | |
| return if tap.blank? || tap.remote.blank? | |
| path = formula.path.relative_path_from(tap.path) | |
| "#{tap.remote}/blob/HEAD/#{path}" | |
| end |
| sig { params(cask: Cask::Cask).returns(T.nilable(String)) } | ||
| def cask_tap_url(cask) | ||
| tap = cask.tap | ||
| return if tap.blank? || tap.remote.blank? | ||
|
|
||
| "#{tap.remote}/blob/HEAD/#{tap.relative_cask_path(cask.token)}" | ||
| end |
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.
| sig { params(cask: Cask::Cask).returns(T.nilable(String)) } | |
| def cask_tap_url(cask) | |
| tap = cask.tap | |
| return if tap.blank? || tap.remote.blank? | |
| "#{tap.remote}/blob/HEAD/#{tap.relative_cask_path(cask.token)}" | |
| end |
| url = c.homepage.presence || cask_tap_url(c) | ||
| url ? "#{c.token} (#{Formatter.url(url)})" : c.token |
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.
| url = c.homepage.presence || cask_tap_url(c) | |
| url ? "#{c.token} (#{Formatter.url(url)})" : c.token | |
| if (homepage = c.homepage.presence) | |
| "#{c.token} (#{Formatter.url(homepage)})" | |
| else | |
| c.token | |
| end |
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.
@MikeMcQuaid If all of them have homepages, why do we check for c.homepage.presence?
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.
@seivan broken or non-homebrew core formulae may not.
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.
You mean taps? I think we should keep the fallbacks in that case, a lot of people use taps. In fact I made one recently because of the gatekeeper issues. It's a diagnostic tool, it should diagnose things that are broken, no?
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.
@seivan I don't think for this debugging tool we should handle the edge cases of "deprecated formulae in taps that fail audits and/or are otherwise broken". It's not worth the extra code.
I find it it a bit frustrating having to do a brew info on each deprecated cask or formula to investigate why things are deprecated, so it would be nice to include URLs, but I didn't want to overload the list, so it will try to pick the best URL to show with the following fallbacks:
Formulas
homepage→head.url (git repo)→tap file URLCasks
homepage→tap file URLbrew lgtm(style, typechecking and tests) with your changes locally?