-
Notifications
You must be signed in to change notification settings - Fork 15
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 of the root package is displayed incorrectly #3
Comments
Umh, this is really strange, because the issue seems to be happening only with the PHAR. I have the same version installed on some of my project, and this is the output:
|
@Jean85 if the same version is installed as a composer dependency, the issue will be not reproducible because it's not a root package in this case. If you start a new git repo and tag a version, then even without packaging a PHAR you'll see the same issue. git init
cat > composer.json <<EOF
{
"name": "test/test",
"require": {
"jean85/pretty-package-versions": "^1.0.2"
}
}
EOF
cat > main.php <<EOF
<?php
require __DIR__ . '/vendor/autoload.php';
echo \Jean85\PrettyVersions::getVersion('test/test')->getPrettyVersion(), PHP_EOL;
EOF
git add .
git commit -mTest
git tag 1.2.3
git checkout 1.2.3
composer install
php main.php
# 1.2.3.0 |
Umh, that's annoying. In this way I'm not sure there's something I can leverage to discern if the requested package is the root one... |
I see at least two solutions:
Alternatively, the logic of building package versions could be augmented, so that instead of the value returned by That last approach looks the hardest but the more correct to me. |
Both the first and last approach would require transforming this package from a simple wrapper into a composer plugin on its own, re-doing the work of |
I've opened Ocramius/PackageVersions#51 that may solve the root cause of this issue. |
Fixed with the 1.0.3 release. |
Thank you @Jean85 for taking care! |
The issue seems regressed by composer/composer@5ba6d7d#diff-8b93719582669d35594f58bb11eed1d2R93. In the highlighted line, the pretty version is rebuilt from the normalized one, so the trailing zero is re-added back. |
I've opened composer/composer#6866 that should finally fix this. |
composer/composer#6866 has been closed, hence this is resolved. |
The tag name is
0.8.5
according to the URL but the displayed version is0.8.5.0
. The same can be seen with any other application using\Jean85\PrettyVersions::getVersion('vendor/package')->getPrettyVersion();
where the vendor/package is the app itself.Looks like when building the version from a git tag, composer/semver pads the version with zeros to have at least 4 numbers (see composer/semver@c1f064e#diff-b25d417df293a1cf205697536aed0410R33).
Not sure if the original tag can be restored from the padded version, but I'd say that most of the packages have 3 numbers in their version, so it should be safe to cut off the trailing zero. Unless there's a better solution.
The text was updated successfully, but these errors were encountered: