From 139345d0093e3677a2a0fe862cdf02b83c043dab Mon Sep 17 00:00:00 2001 From: Remi Collet Date: Mon, 30 Dec 2024 09:10:20 +0100 Subject: remove 'v' in version number --- composer.prov | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) (limited to 'composer.prov') diff --git a/composer.prov b/composer.prov index d866711..d8bb84d 100755 --- a/composer.prov +++ b/composer.prov @@ -16,32 +16,35 @@ */ // Check if composer "pretty_version" is usable in RPM -function isValid($version) { - if (empty($version) - || strpos($version, '-') +function isValid(Array $package) { + if (!isset($package['pretty_version']) + || empty($package['pretty_version']) + || strpos($package['pretty_version'], '-') ) { return false; } return true; } +// Clean"pretty_version" +function getVersion(Array $package) { + return ltrim($package['pretty_version'], 'v'); +} + // Parse an installed.php file function run($file) { fputs(STDERR, "Search bundled libraries installed, parsing $file\n"); $installed = include $file; $main = false; if (isset($installed['root']['name']) - && isset($installed['root']['pretty_version']) - && isValid($installed['root']['pretty_version'])) { + && isValid($installed['root'])) { $main = $installed['root']['name']; - printf("php-composer(%s) = %s\n", $installed['root']['name'], $installed['root']['pretty_version']); + printf("php-composer(%s) = %s\n", $installed['root']['name'], getVersion($installed['root'])); } if (isset($installed['versions'])) foreach($installed['versions'] as $name => $v) { - if ($name !== $main - && isset($v['pretty_version']) - && isValid($v['pretty_version'])) { - printf("bundled(php-composer(%s)) = %s\n", $name, $v['pretty_version']); + if ($name !== $main && isValid($v)) { + printf("bundled(php-composer(%s)) = %s\n", $name, getVersion($v)); } } } -- cgit