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

Formulary: map formula names to local bottle paths #11534

Merged
merged 5 commits into from
Jun 17, 2021
Merged

Formulary: map formula names to local bottle paths #11534

merged 5 commits into from
Jun 17, 2021

Conversation

Rylan12
Copy link
Member

@Rylan12 Rylan12 commented Jun 14, 2021

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run brew style with your changes locally?
  • Have you successfully run brew typecheck with your changes locally?
  • Have you successfully run brew tests with your changes locally?

This PR adds some new functionality to Formulary to allow for refs to be mapped to each other. This mapping is set up using Formulary::map and is then used to substitute the reference passed to Formulary::factory. For example:

Formulary.factory "foo"        # error
Formulary.map "foo", to: "bar" # setup mapping
Formulary.factory "foo"        # returns the bar formula

At the moment, this is not used anywhere internally, but would be used in Homebrew/json if merged. Originally, I had opted to monkey patch Formulary to look for cached bottles and was a bit unwilling to add it to Homebrew/brew because it felt too specific to that tap. However, I rethought the process a bit over the weekend and am now planning on monkey patching the changes from this PR (essentially). Since these changes feel more general and don't need to be specific to Homebrew/json, I feel okay including them here.

If the consensus is that we don't want it to be added here unless we're using it internally, that's okay.

@BrewTestBot
Copy link
Member

Review period will end on 2021-06-15 at 16:07:27 UTC.

@BrewTestBot BrewTestBot added the waiting for feedback Merging is blocked until sufficient time has passed for review label Jun 14, 2021
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.

I'm fine with this functionality being included and merged but it feels a bit generic to me. If this is for cached bottles specifically: let's make the naming and example documentation reference those specifically. A generic map function seems both undesirable and potentially dangerous/insecure.

@BrewTestBot BrewTestBot added waiting for feedback Merging is blocked until sufficient time has passed for review and removed waiting for feedback Merging is blocked until sufficient time has passed for review labels Jun 15, 2021
@Rylan12
Copy link
Member Author

Rylan12 commented Jun 15, 2021

Is this better?

Comment on lines 416 to 418
# Map a formula name to a bottle archive. This mapping will be used by {Formulary::factory}
# to allow formulae to be loaded automatically from their bottle archive without
# needing to exist in a tap or be passed as a complete filepath. For example,
Copy link
Member

Choose a reason for hiding this comment

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

Could it be used now if an environment variable is set?

Copy link
Member Author

Choose a reason for hiding this comment

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

Used how? What would the environment variable do? Right now there's no place where it makes sense to set up the mapping outside of Homebrew/json. So I don't think adding an environment variable would do much here. As soon as this and https://github.com/Homebrew/homebrew-json/pull/7 are merged, anyone using Homebrew/json would use this

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.

Yes, much better naming etc. 👏🏻

@BrewTestBot
Copy link
Member

Review period ended.

@BrewTestBot BrewTestBot removed the waiting for feedback Merging is blocked until sufficient time has passed for review label Jun 15, 2021
BrewTestBot
BrewTestBot previously approved these changes Jun 15, 2021
@Rylan12
Copy link
Member Author

Rylan12 commented Jun 16, 2021

Ah, I see. Those suggestions make sense to me.

Just thinking ahead a bit, is this the same env variable you're anticipating will be used to control whether homebrew/core is allowed to be untapped?

@Rylan12 Rylan12 changed the title Formulary: add ::map to map formula refs Formulary: map formula names to local bottle paths Jun 16, 2021
@MikeMcQuaid
Copy link
Member

Ah, I see. Those suggestions make sense to me.

Just thinking ahead a bit, is this the same env variable you're anticipating will be used to control whether homebrew/core is allowed to be untapped?

It could be, yes, so feel rename to rename it accordingly 👍🏻

@Rylan12
Copy link
Member Author

Rylan12 commented Jun 17, 2021

I think I'll go ahead and merge for now. I have a work-in-progress PR for untapping homebrew/core, so we can figure out the env var name there. Since its all undocumented and unsupported I'm fine changing it.

@Rylan12 Rylan12 merged commit 1cb0f0f into Homebrew:master Jun 17, 2021
@Rylan12 Rylan12 deleted the formulary-map branch June 17, 2021 16:26
@github-actions github-actions bot added the outdated PR was locked due to age label Jul 18, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jul 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
outdated PR was locked due to age
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants