-
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Implement version_schemes #719
Conversation
all_versions << version | ||
|
||
return [] if pkg_version <= version && !version.head? | ||
return [] if pkg_version <= version && epoch == tab.epoch && !version.head? |
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.
Can you split this into multiple statements/lines somehow? Quite a bit of logic being chained here; perhaps having 2-3 separate variables would help.
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 can come up with this:
if !version.head?
return [] if epoch == tab.epoch && pkg_version <= version
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.
How about:
outdated_version = pkg_version <= version
equal_epoch = epoch == tab.epoch
not_head_version = !version.head?
return [] if outdated_version && equal_epoch && not_head_version
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.
outdated_version
is actually not_outdated_version
.
I don't really like not
prefixes, but If you're OK with them I make the change. Also, equal_epoch
can be done same_epoch
.
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.
latest_version
, same_epoch
, not_head
perhaps (as I can't think of a way of decribing "not head" without "not").
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.
👍 will make the change.
Great work on this, @vladshablinsky. Could you make a PR to homebrew-core with an example that we could use to test (and merge after this is done) and some commands to run to test this? |
CC @DomT4 too who will be interested in this. |
a3babbc
to
f551d7d
Compare
Thanks for working on this @vladshablinsky ❤️. Will play with this later tonight locally a bit; currently working on GPG stuff, which is being "fun". |
I tested this with Homebrew/homebrew-core#3900 and it worked great. I installed the As far as I'm concerned this is good to 🚢. The only wording I might want to adjust is |
Also: I want to get this merged sooner rather than later so if @DomT4 agrees on one of those names let's try and get this shipped this week. |
Will change it to |
latest_version = pkg_version <= version | ||
same_version_scheme = version_scheme == tab.version_scheme | ||
not_head = !version.head? | ||
return [] if latest_version && same_version_scheme && not_head |
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 think this should be:
latest_version = pkg_version <= version
latest_version_scheme = version_scheme <= tab.version_scheme
not_head = !version.head?
return [] if (latest_version || latest_version_scheme) && not_head
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.
Let's pull it out to:
latest_version = pkg_version <= version
latest_version_scheme = version_scheme <= tab.version_scheme
latest_version_or_scheme = latest_version || latest_version_scheme
not_head = !version.head?
return [] if latest_version_or_scheme && not_head
(to simplify humans parsing the binary logic)
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.
How about:
installed_kegs.each do |keg|
version = keg.version
tab = Tab.for_keg(keg)
all_versions << version
next if version.head?
next if version_scheme > tab.version_scheme
next if pkg_version > version
return []
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.
Even better. Could skip creating the tab
until after version.head?
when we know it's needed, too.
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.
Actually, I just realize I gave an incorrect suggestion in the first place. The correct way is:
installed_kegs.each do |keg|
version = keg.version
tab = Tab.for_keg(keg)
all_versions << version
next if version.head?
next if version_scheme > tab.version_scheme
next if version_scheme == tab.version_scheme && pkg_version > version
return []
end
Noted that the correct way to compare two versions is:
(version_scheme <=> other.version_scheme).nonzero? || pkg_version <=> other.pkg_version
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.
Would be good to make next if version_scheme == tab.version_scheme && pkg_version > version
into two variables which are &&
to again make the boolean logic better.
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.
And, again, moving Tab.for_keg(keg)
after version.head?
so it's not read unnecessariy.
I like I can live with I think it's worth adding |
FWIW I'd done Debian packaging before and never heard epoch used this way so I think this is catering for a very small group of people.
Agreed (but in a follow-up PR). |
Doesn't need to be a blocker here but would like it chased up on before we start using this in |
Tested this again locally and it worked great. Nice work @vladshablinsky 👏 |
Done in #743. |
I saw this too late, but IMO |
@dunn It's a migration between versioning schemes e.g. |
Oh I know, but to me it suggests the DSL is for specifying the scheme, rather than the versioning scheme ... version 😸 |
Are updates to taps occurring before updates to the main brew code?
|
@ilovezfs They are not but did you have a non-master |
ah nevermind I think I know what happened. |
Also that exception is only printed for developers. |
@MikeMcQuaid yeah, that particular tree is on non-master since it has my version of bump-formula-pr. |
PR requested 😉 |
brew tests
with your changes locally?Issue: Homebrew/legacy-homebrew#41563
The idea is to add
epoch
to DSL and reimplementoutdated_versions
-related things to be able to change version schemes, thus epochs are quite similar to revisions, but we store them in tabs.CC @xu-cheng