Skip to content
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

Fix brew info --json regressions around install status #14609

Merged
merged 1 commit into from
Feb 13, 2023

Conversation

Bo98
Copy link
Member

@Bo98 Bo98 commented Feb 13, 2023

#14587 unfortunately introduced some notable regressions to brew info --json:

  • Installed version tracking stopped working, including the outdated boolean (very popularly used in scripts).
  • There was an API break where "token" was missing from casks and "name" was missing from formulae.

This PR fixes this by:

  • Adding the local install info & the token to the cask output hash.
  • Largely reverting the changes to Formula#to_hash to instead take from the local state (our Formulary work means this works fine), except for oldname and requirements. In a future 4.0.x release, this will likely go away in favour of reading that data on the Formulary side. I'll make a PR after 4.0.0 with that - I'm keeping this PR as low risk as possible by only touching the broken functions.
  • Changing Formula#to_hash_with_variation to take both the local hash and API hash and take the relevant bits from both.

Fixes #14600.

@Bo98 Bo98 added the critical Critical change which should be shipped as soon as possible. label Feb 13, 2023
@BrewTestBot
Copy link
Member

Review period skipped due to critical label.

@Bo98 Bo98 added the install from api Relates to API installs label Feb 13, 2023
Copy link
Contributor

@apainintheneck apainintheneck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we sure that the API is necessary when printing the info for formulae? The original issue (#14541) only referenced problems related to cask info generation. It could have been broken before that though or there may have been another issue I missed as well.

Also, it'd be really nice if there was a small regression test that we could add so this sort of thing doesn't happen again.

Comment on lines +2183 to +2189
# TODO: can we implement these in Formulary?
if self.class.loaded_from_api && Homebrew::EnvConfig.install_from_api?
json_formula = Homebrew::API::Formula.all_formulae[name]
json_formula = Homebrew::API.merge_variations(json_formula)
hsh["oldname"] = json_formula["oldname"]
hsh["requirements"] = json_formula["requirements"]
end
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Were these things missing even before the most recent regression?

Copy link
Member Author

@Bo98 Bo98 Feb 13, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. I hand tested by comparing with and without HOMEBREW_NO_INSTALL_FROM_API. See qt@5 as an example.

We do not currently read requirements or oldname from the JSON file. This will be fixed after 4.0.0 - I don't think people would be happy if I tried to get something larger before 4.0.0. 😅

Variations also don't work without the original source, hence why that has the hybrid of API + local.

Copy link
Member

@MikeMcQuaid MikeMcQuaid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work again @Bo98!

@MikeMcQuaid MikeMcQuaid merged commit 2a417f1 into Homebrew:master Feb 13, 2023
@Bo98 Bo98 deleted the json-fix branch February 13, 2023 15:03
@github-actions github-actions bot added the outdated PR was locked due to age label Mar 16, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
critical Critical change which should be shipped as soon as possible. install from api Relates to API installs outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

brew info --json=v2 "version" not updated after upgrade
4 participants