Skip to content

formulary: remove consts on cache clear#10642

Merged
MikeMcQuaid merged 2 commits intoHomebrew:masterfrom
Bo98:formulary-remove_const
Feb 18, 2021
Merged

formulary: remove consts on cache clear#10642
MikeMcQuaid merged 2 commits intoHomebrew:masterfrom
Bo98:formulary-remove_const

Conversation

@Bo98
Copy link
Copy Markdown
Member

@Bo98 Bo98 commented Feb 17, 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?
  • Have you successfully run brew man locally and committed any changes?

Fixes this -W1 warning:

/usr/local/Homebrew/Library/Homebrew/formulary.rb:47: warning: already initialized constant Formulary::FormulaNamespace05bf70582f35fd2a829a4b3b42cd7164
/usr/local/Homebrew/Library/Homebrew/formulary.rb:47: warning: previous definition of FormulaNamespace05bf70582f35fd2a829a4b3b42cd7164 was here

Steps to reproduce:

Formula["hello"]
Formulary.clear_cache
Formula["hello"]

@BrewTestBot
Copy link
Copy Markdown
Contributor

Review period will end on 2021-02-18 at 15:15:52 UTC.

@BrewTestBot BrewTestBot added the waiting for feedback Merging is blocked until sufficient time has passed for review label Feb 17, 2021
@Bo98 Bo98 force-pushed the formulary-remove_const branch 3 times, most recently from 78910fc to a111c71 Compare February 17, 2021 16:18
Copy link
Copy Markdown
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 catch!

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
next unless namespace.deconstantize == name
next if namespace.deconstantize != name

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
cache.each do |k, m|
cache.each do |klass, module|

assuming that's correct?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

k for key since it's either a pathname or a symbol - it's not consistent. But yes, I'll change these.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Ta!

@Bo98 Bo98 force-pushed the formulary-remove_const branch from a111c71 to da9e42f Compare February 17, 2021 17:13
@Bo98
Copy link
Copy Markdown
Member Author

Bo98 commented Feb 17, 2021

Also added a fix for another scenario when formula loading failed (it would not be stored in the cache but the const would remain).

@BrewTestBot
Copy link
Copy Markdown
Contributor

Review period ended.

@BrewTestBot BrewTestBot removed the waiting for feedback Merging is blocked until sufficient time has passed for review label Feb 18, 2021
@MikeMcQuaid MikeMcQuaid merged commit baf61b2 into Homebrew:master Feb 18, 2021
@MikeMcQuaid
Copy link
Copy Markdown
Member

Great, thanks for this @Bo98!

@Bo98 Bo98 deleted the formulary-remove_const branch February 18, 2021 18:51
@BrewTestBot BrewTestBot added the outdated PR was locked due to age label Mar 21, 2021
@Homebrew Homebrew locked as resolved and limited conversation to collaborators Mar 21, 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