Skip to content

Refactor: Replace jean85/pretty-package-versions with native Composer\InstalledVersions - #2171

Open
peter17 wants to merge 1 commit into
getsentry:masterfrom
peter17:patch1
Open

Refactor: Replace jean85/pretty-package-versions with native Composer\InstalledVersions#2171
peter17 wants to merge 1 commit into
getsentry:masterfrom
peter17:patch1

Conversation

@peter17

@peter17 peter17 commented Jul 28, 2026

Copy link
Copy Markdown

Summary

Now that Composer 2 is standard across the ecosystem, Composer\InstalledVersions (provided natively via composer-runtime-api ^2.0) is available out of the box.

This PR removes our dependency on jean85/pretty-package-versions and updates ModulesIntegration.php to call Composer\InstalledVersions::getPrettyVersion() directly.

Rationale

  • Native Runtime API: Composer 2 provides Composer\InstalledVersions natively, making third-party helper wrappers unnecessary for Composer 2+ environments.
  • Supply-Chain Security & Reduced Footprint: Preferring native APIs maintained directly by official project organizations (like Composer itself) helps minimize our overall dependency footprint and reduces potential supply-chain
    attack surface.
  • Huge thanks to jean85 for maintaining pretty-package-versions over the years—it served the community fantastically through the Composer 1 era!

Changes

  • In composer.json: Replaced jean85/pretty-package-versions with "composer-runtime-api": "^2.0".
  • In ModulesIntegration: Switched version resolution to InstalledVersions::getPrettyVersion($package) and removed Composer 1 legacy fallback logic.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 184acee. Configure here.

$prettyVersion = InstalledVersions::getPrettyVersion($package);

if ($prettyVersion !== null) {
self::$packages[$package] = $prettyVersion;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Dev versions lose commit identity

Medium Severity

PrettyVersions::getVersion()->getPrettyVersion() is not equivalent to InstalledVersions::getPrettyVersion(). For non-tagged installs, the former appended a short commit reference, while Composer’s API returns only the branch/pretty string. Module data on Sentry events can no longer identify the exact revision for branch or VCS packages.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 184acee. Configure here.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

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

If this is really an issue, would something like this be acceptable?

$prettyVersion = InstalledVersions::getPrettyVersion($package);
if ($prettyVersion !== null) {
    $reference = InstalledVersions::getReference($package);
    if ($reference !== null && str_starts_with($prettyVersion, 'dev-')) {
        $prettyVersion .= '@' . substr($reference, 0, 7);
    }
    self::$packages[$package] = $prettyVersion;
}

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.

1 participant