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

use first non development version as download if possible #283

Conversation

jg-development
Copy link

The problem with the first version is sometimes that the first version (depending on import) is a dev version with a source to a forbidden gitlab/github repo.
Only the non-development version omits the source and has only a dist with a download.

This results in a 401, if the zipball wants to download the dev version, not the non-development version.

            "2.4.x-dev": {
                "name": "mageplaza\/module-seo-url",
                "version": "2.4.x-dev",
                "version_normalized": "2.4.9999999.9999999-dev",
                "source": {
                    "type": "git",
                    "url": "[email protected]:mageplaza\/artemis\/module-seo-url.git",
                    "reference": "XXXXX"
                },
                "dist": {
                    "type": "zip",
                    "url": "https:\/\/gitlab.com\/api\/v4\/projects\/mageplaza%2Fartemis%2Fmodule-seo-url\/repository\/archive.zip?sha=XXXXX",
                    "reference": "XXXXX",
                    "shasum": ""
                },
...


            "4.1.4": {
                "name": "mageplaza\/module-seo-url",
                "version": "4.1.4",
                "version_normalized": "4.1.4.0",
                "dist": {
                    "type": "zip",
                    "url": "https:\/\/repo.mageplaza.com\/public\/dist\/mageplaza\/module-seo-url\/mageplaza-module-seo-url-XXXXX.zip",
                    "reference": "XXXXX",
                },
...

}
}
}
return $matchedVersions[0]->first();
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$matchedVersions[0]->first() may return false

@@ -536,7 +536,18 @@ public function getVersions()

public function getVersionByReference(string $reference): ?Version
{
return $this->versions->findFirst(fn($k, $v) => $v->getReference() === $reference);
/** @var ArrayCollection[] $matchedVersions */
$matchedVersions = $this->versions->partition(fn($k, $v) => $v->getReference() === $reference);
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use filter method here

$this->versions->filter(fn($k, $v) => $v->getReference() === $reference);

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.

2 participants