Skip to content

Commit

Permalink
Merge pull request #201 from hrs-o/update/dumper-stability
Browse files Browse the repository at this point in the history
fix processing for RC version
  • Loading branch information
pierrejoye authored Jan 16, 2021
2 parents ab32a54 + fc5d1a9 commit fec521d
Showing 1 changed file with 19 additions and 6 deletions.
25 changes: 19 additions & 6 deletions src/Package/Util/Dumper.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@

namespace Pickle\Package\Util;

use Composer\Semver\VersionParser;
use Pickle\Base\Interfaces;

class Dumper
Expand All @@ -52,12 +53,7 @@ public function dump(Interfaces\Package $package, $with_version = true)
$data['name'] = $package->getPrettyName();

if ($with_version) {
$data['version'] = $package->getPrettyVersion();
$stability = $package->getStability();

if ('stable' !== $stability) {
$data['version'] .= '-' . $stability;
}
$data['version'] = $this->getVersion($package);
}

$data['type'] = $package->getType();
Expand All @@ -84,6 +80,23 @@ public function dump(Interfaces\Package $package, $with_version = true)

return $data;
}

/**
* @param Interfaces\Package $package
*
* @return string
*/
private function getVersion(Interfaces\Package $package): string
{
$version = $package->getPrettyVersion();
$version_stability = VersionParser::parseStability($version);
$stability = $package->getStability();

if ('beta' === $stability && 'stable' === $version_stability) {
return $version . '-' . $stability;
}
return $version;
}
}

/* vim: set tabstop=4 shiftwidth=4 expandtab: fdm=marker */

0 comments on commit fec521d

Please sign in to comment.