Skip to content
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

Merged

Conversation

JCount
Copy link
Contributor

@JCount JCount commented Jun 26, 2017

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same change?
  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes? Here's an example.
  • Have you successfully run 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

@JCount JCount force-pushed the version-improve-url-only-version-parsing branch from b097534 to a7251a9 Compare June 26, 2017 21:59
# 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)
Copy link
Member

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?

Copy link
Contributor Author

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, 🤔.

Copy link
Member

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 👍

@MikeMcQuaid
Copy link
Member

Nice work @JCount. One question on this.

@JCount JCount force-pushed the version-improve-url-only-version-parsing branch from a7251a9 to e77adf3 Compare June 29, 2017 18:59
@JCount
Copy link
Contributor Author

JCount commented Jun 29, 2017

@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
@JCount JCount force-pushed the version-improve-url-only-version-parsing branch from 0bf56a6 to d50312a Compare June 30, 2017 14:54
@JCount
Copy link
Contributor Author

JCount commented Jun 30, 2017

@MikeMcQuaid Rebased again so all the regex changes are in one commit to make the commit history a bit less fragmented.

@JCount JCount merged commit 0a50521 into Homebrew:master Jun 30, 2017
@JCount JCount deleted the version-improve-url-only-version-parsing branch June 30, 2017 15:37
@Homebrew Homebrew locked and limited conversation to collaborators May 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants