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
resolve_latest_keg
should return the latest HEAD keg when no stable kegs exist
#11824
Conversation
Review period will end on 2021-08-05 at 22:58:17 UTC. |
The test is failing on CI (but passing for me locally) because at the moment, comparing two HEAD versions returns 0. I suspect the best way to deal with this would be in |
I can take a closer look late tomorrow night (might not be until Friday—traveling today).
brew/Library/Homebrew/formula.rb Lines 549 to 558 in 0fc7762
I think it would be appropriate to use the same logic here (ideally this could be done without duplicating code but it's possible some refactoring would need to be done to support that) |
Thanks for pointing me towards |
Review period ended. |
kegs.reject { |k| k.version.head? }.max_by(&:version) | ||
stable_kegs = kegs.reject { |k| k.version.head? } | ||
|
||
return kegs.max_by { |keg| Tab.for_keg(keg).source_modified_time } if stable_kegs.blank? |
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 included the source_modified_time
code here directly since it is so brief. If you think this should be encapsulated elsewhere for use in resolve_latest_keg
and latest_head_version
, I'm happy to make changes. @Rylan12
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.
@cnnrmnn I think this is fine. I'm not sure it really makes much sense to extract what's essentially #source_modified_time
to its own method.
Just making sure, the revision
secondary sort from Formula#latest_head_version
isn't necessary here, right?
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'm not sure that the revision
secondary sort is needed anywhere we're dealing exclusively with HEAD
versions. If you check out the parsing function for PkgVersion
, you'll see that it parses the revision using a regex. HEAD
paths (e.g., HEAD-6974ce8
) matched to that regex will always set revision
to nil. Any HEAD
version should have a revision equal to 0
since to_i
is called on the parsed nil
revision
.
Am I missing anything?
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.
Gotcha makes sense. So it could probably be removed from latest_head_version
too, right? Probably not worth doing but just curious if there's a difference.
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.
So it could probably be removed from latest_head_version too, right?
Yep, should be fine to remove. I can do that in a quick PR as to not confuse anyone dealing with that code in the future.
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.
You definitely don't need to but it probably wouldn't hurt. Plus it will expose more maintainers to it in case anyone knows something we're missing and it turns out it is necessary
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.
@Rylan12 Did some quick digging, and found a spec that tests HEAD
versions with revisions. Do you know if there's any scenario where a HEAD
version would actually have a revision?
I would think so given that the above test exists, but I'm still curious. If you don't know, I can do a little more digging and restore the secondary sort here if appropriate.
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.
Ah, good call. If you do brew install --HEAD
on a formula that's specified a revision
it will show up as HEAD-6974ce8_3
(which means there will be a revision), so I think it does need to be added here.
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.
Gotcha, will push a fix shortly.
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.
Makes sense to me. Thanks @cnnrmnn!
brew style
with your changes locally?brew typecheck
with your changes locally?brew tests
with your changes locally?Closes #11741.
Currently,
resolve_latest_keg
has the following behavior:This behavior doesn't handle the case where there are multiple HEAD kegs, but no stable kegs. This PR adds the following behavior to
resolve_latest_keg
: