formula: reject only the latest head keg when cleaning up #11475
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?Follow up to #11438. See #11438 (comment)
Version
s can be compared to each other using so using.sort_by(&:version)
works fine.HeadVersion
s, though, cannot be compared in this way. Instead, the latest version is found by checking the time the tab was modified (done inFormula#latest_head_version
).Since
.sort_by(&:version)
on and array of HEAD kegs just returns the same array (of which all items except for the last were selected for cleanup), it is arbitrary which HEAD version doesn't get selected for cleanup.Instead of sorting the HEAD keg array, I've chosen to just remove the latest HEAD keg as found using
Formula#latest_head_version
. This is essentially the same behavior that existed prior to #11438.Here's the net diff of #11438 and this PR: