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
version: improve url-only version parsing #2827
version: improve url-only version parsing #2827
Conversation
b097534
to
a7251a9
Compare
Library/Homebrew/version.rb
Outdated
# e.g. https://wwwlehre.dhbw-stuttgart.de/~sschulz/WORK/E_DOWNLOAD/V_1.9/E.tgz | ||
# e.g. https://github.com/JustArchi/ArchiSteamFarm/releases/download/2.3.2.0/ASF.zip | ||
# e.g. https://people.gnome.org/~newren/eg/download/1.7.5.2/eg | ||
m = %r{/[a-z_]{,2}(\d\.\d+(\.\d+){,2})}i.match(spec_s) |
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.
What's the [a-z_]{,2}
and (.\d+){,2} handling?
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.
@MikeMcQuaid My attempted explanation follows:
-
The
[a-z_]{,2}
, combined with the case-insensitive modifier, will handle cases where the version substring in the url is prefixed by a combination of zero to two letters or underscores. This will handle, from the examples I've given,/releases/download/r1.9.293/cljs.jar
,/download/v0.6.1/fullsrc.zip
, and/WORK/E_DOWNLOAD/V_1.9/E.tgz
. -
(\.\d+){,2}
will handle instances where there are, in addition to the two,.
separated base groups of digits, an additional one to two.
prefixed digit groupings concatenated onto that base, for a total of up to four groupings of digits separated by.
s. This will handle, for example,/download/2.3.2.0/ASF.zip
and/download/1.7.5.2/eg
, while not breaking the new handling of/WORK/E_DOWNLOAD/V_1.9/E.tgz
.
I apologize for the awkward language, it is difficult to turn regex into understandable language, 🤔.
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 handle cases where the version substring in the url is prefixed by a combination of zero to two letters or underscores
I'd make this more specific e.g. [rvV]_?
will handle instances where there are, in addition to the two
This one makes sense 👍
Nice work @JCount. One question on this. |
a7251a9
to
e77adf3
Compare
@MikeMcQuaid Rebased |
add support for styles prefixed with a r,v,V and an optional _ , and styles with four groups of digits, seperated by periods; combinations of the two are also supported
0bf56a6
to
d50312a
Compare
@MikeMcQuaid Rebased again so all the regex changes are in one commit to make the commit history a bit less fragmented. |
brew tests
with your changes locally?add support for both styles prefixed with up to two characters,
and styles with four groups of digits, seperated by periods
I believe I made the regex sufficiently strict to prevent unwanted results, but if necessary it could be split into two or more pieces. Some of the regex syntax itself is also more esoteric so it may be desirable to modify them for that reason as well.
Originally begun as a fix for homebrew/core#14957.
I added tests, which is good, but did I add too many?
cc @ilovezfs @dunn