-
-
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
update: Don't report formulae that are moved within a tap but not renamed #480
update: Don't report formulae that are moved within a tap but not renamed #480
Conversation
# Don't report formulae that are moved within a tap but not renamed | ||
next if src_full_name == dst_full_name | ||
@report[:D] << src_full_name if tap.formula_file?(src) | ||
@report[:A] << dst_full_name if tap.formula_file?(dst) |
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.
There's a very subtle problem with these two lines. If formulae happen to be moved within a tap and a formula gets renamed before or afterwards (thus src_full_name != dst_full_name
) and the update covers both operations, then the report will look something like this (I experimented a bit with my local copy of the homebrew/gui
tap):
Updated 1 tap (homebrew/gui).
==> New Formulae
homebrew/gui/xchat2
But it should have looked something like this:
Updated 1 tap (homebrew/gui).
==> Renamed Formulae
homebrew/gui/xchat -> homebrew/gui/xchat2
The reason is that if tap.formula_file?(src)
will always be false
as it checks against the current Tap#formula_dir
. It's admittedly a rare corner case, but this should solve it:
if tap.formula_file?(dst)
@report[:D] << src_full_name
@report[:A] << dst_full_name
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.
Nice catch! Fixed in f1a7eb6
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 for finding an even more elegant solution and particularly for adding a nice test case!
Thanks for taking a look and for this PR! I commented on a corner case, but otherwise it's looking good. Unfortunately, other parts of Homebrew also assume that |
@@ -209,8 +209,13 @@ def report | |||
end | |||
@report[:M] << tap.formula_file_to_name(src) | |||
when /^R\d{0,3}/ | |||
@report[:D] << tap.formula_file_to_name(src) if tap.formula_file?(src) | |||
@report[:A] << tap.formula_file_to_name(dst) if tap.formula_file?(dst) | |||
next unless tap.formula_file?(dst) |
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 just realized this check can be dropped completely, as there's a check preceding the case
statement that already makes sure that at least one of the modified paths is a formula file:
next unless paths.any? { |p| tap.formula_file?(p) }
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.
Got it, removed in 7195878.
Merged in 4abdeb7. Thank you for this contribution to Homebrew, @jawshooah! 🎉 Sorry for the long delay! I'd be still interested in your answer to the following question:
|
@UniqMartin No worries! Sorry for the delay in getting back to you. I haven't looked too deeply into |
brew tests
with your changes locally?It's misleading to report a formula as "new" when it's only been moved from one directory to another within the same tap.
Ref: caskroom/homebrew-cask#22669 (comment)