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

Properly compare multiple package versions #380

Merged
merged 2 commits into from
Oct 30, 2021

Conversation

hugopeek
Copy link
Contributor

What does it do ?

Fix a silly mistake.

Why is it needed ?

I assumed that the max() function was able to figure out the highest semantic version number, but of course it's not that easy. Gitify selected 1.9.0 instead of 1.11.1 in my latest test, so apparently 1.9 was seen as higher than 1.1.

So the whole semantic version string needs to be picked apart and compared. Fortunately there's a version_compare function available in PHP that does just that, so it's now able to sniff out the actual latest version from the packageVersions array. Regardless of position. It even evaluates -alpha and -beta suffixes, so those should be correctly evaluated now too! They did for me with a test array.

Related issue(s)/PR(s)

#327

@Mark-H
Copy link
Member

Mark-H commented Oct 17, 2021

Devil's advocate; do we always want it to install latest?

@hugopeek
Copy link
Contributor Author

Devil's advocate; do we always want it to install latest?

Hmm.. You mean with alpha / beta versions? That's a good one.

But if you don't want that, you can always specify the full signature (redactor-2.4.0-pl).

And to clarify: this is only for packages that offer multiple versions under the same name. In my experience, ModMore is the only package provider doing that. And you even have a setting for pre-releases in your account settings ;)

@Mark-H
Copy link
Member

Mark-H commented Oct 27, 2021

Indeed, bit of a shame it's not better supported. It's nice to give the choice ;)

@muzzwood
Copy link
Contributor

I've been testing this out this afternoon, and no issues found, nice work @hugopeek
Specifying the exact version you want does allow you to not just get the latest.

I do agree with @Mark-H that it would be great to offer a choice for when multiple versions are offered by the modmore provider. e.g.:

Array
(
    [0] => Array
        (
            [name] => Redactor
            [version] => 3.1.2
            [location] => https://rest.modmore.com/package/download?api_key=123&database=mysql&revolution_version=Revolution-2.8.3-pl&http_host=localhost&package=1&version=redactor-3.1.2-pl
            [signature] => redactor-3.1.2-pl
        )

    [1] => Array
        (
            [name] => Redactor
            [version] => 3.0.2
            [location] => https://rest.modmore.com/package/download?api_key=123&database=mysql&revolution_version=Revolution-2.8.3-pl&http_host=localhost&package=1&version=redactor-3.0.2-pl
            [signature] => redactor-3.0.2-pl
        )

    [2] => Array
        (
            [name] => Redactor
            [version] => 2.4.0
            [location] => https://rest.modmore.com/package/download?api_key=123&database=mysql&revolution_version=Revolution-2.8.3-pl&http_host=localhost&package=1&version=redactor-2.4.0-pl
            [signature] => redactor-2.4.0-pl
        )

)

Though I think perhaps that could be built into the interactive mode. Currently specifying --interactive will let you answer yes or no to installing each package in the list, but it would be more useful when there's a potential choice to allow a number to be entered:

Which version of Redactor would you like to install?
1) 3.1.2-pl
2) 3.0.2-pl
3) 2.4.0-pl
4) Do not install Redactor.

I'll merge this now, and look at adding this choice in the near future.

@muzzwood muzzwood merged commit 8904e9b into modmore:master Oct 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants