1
0
Fork 0

Add minimum-stability flag on root package to filter packages by stability

pull/592/head
Jordi Boggiano 2012-04-18 01:33:47 +02:00
parent b0134b56c5
commit 66068fedcb
5 changed files with 66 additions and 7 deletions

View File

@ -143,6 +143,10 @@
"description": "A set of additional repositories where packages can be found.", "description": "A set of additional repositories where packages can be found.",
"additionalProperties": true "additionalProperties": true
}, },
"minimum-stability": {
"type": ["string"],
"description": "The minimum stability the packages must have to be install-able. Possible values are: dev, alpha, beta, RC, stable."
},
"bin": { "bin": {
"type": ["array"], "type": ["array"],
"description": "A set of files that should be treated as binaries and symlinked into bin-dir (from config).", "description": "A set of files that should be treated as binaries and symlinked into bin-dir (from config).",

View File

@ -14,17 +14,35 @@ namespace Composer\DependencyResolver;
use Composer\Package\LinkConstraint\LinkConstraintInterface; use Composer\Package\LinkConstraint\LinkConstraintInterface;
use Composer\Repository\RepositoryInterface; use Composer\Repository\RepositoryInterface;
use Composer\Repository\CompositeRepository;
use Composer\Repository\InstalledRepositoryInterface;
use Composer\Repository\PlatformRepository;
/** /**
* A package pool contains repositories that provide packages. * A package pool contains repositories that provide packages.
* *
* @author Nils Adermann <naderman@naderman.de> * @author Nils Adermann <naderman@naderman.de>
* @author Jordi Boggiano <j.boggiano@seld.be>
*/ */
class Pool class Pool
{ {
protected $repositories = array(); protected $repositories = array();
protected $packages = array(); protected $packages = array();
protected $packageByName = array(); protected $packageByName = array();
protected $acceptableStabilities;
public function __construct($minimumStability = 'dev')
{
$stabilities = array(
'stable',
'RC',
'beta',
'alpha',
'dev',
);
$this->acceptableStabilities = array_flip(array_splice($stabilities, 0, array_search($minimumStability, $stabilities) + 1));
}
/** /**
* Adds a repository and its packages to this package pool * Adds a repository and its packages to this package pool
@ -33,9 +51,21 @@ class Pool
*/ */
public function addRepository(RepositoryInterface $repo) public function addRepository(RepositoryInterface $repo)
{ {
if ($repo instanceof CompositeRepository) {
$repos = $repo->getRepositories();
} else {
$repos = array($repo);
}
foreach ($repos as $repo) {
$this->repositories[] = $repo; $this->repositories[] = $repo;
$exempt = $repo instanceof PlatformRepository || $repo instanceof InstalledRepositoryInterface;
foreach ($repo->getPackages() as $package) { foreach ($repo->getPackages() as $package) {
if (!$exempt && !isset($this->acceptableStabilities[$package->getStability()])) {
continue;
}
$package->setId(count($this->packages) + 1); $package->setId(count($this->packages) + 1);
$this->packages[] = $package; $this->packages[] = $package;
@ -44,6 +74,7 @@ class Pool
} }
} }
} }
}
public function getPriority(RepositoryInterface $repo) public function getPriority(RepositoryInterface $repo)
{ {

View File

@ -207,7 +207,7 @@ class Installer
} }
// creating repository pool // creating repository pool
$pool = new Pool; $pool = new Pool($this->package->getMinimumStability());
$pool->addRepository($installedRepo); $pool->addRepository($installedRepo);
foreach ($this->repositoryManager->getRepositories() as $repository) { foreach ($this->repositoryManager->getRepositories() as $repository) {
$pool->addRepository($repository); $pool->addRepository($repository);

View File

@ -76,6 +76,10 @@ class RootPackageLoader extends ArrayLoader
$package->setAliases($aliases); $package->setAliases($aliases);
} }
if (isset($config['minimum-stability'])) {
$package->setMinimumStability($config['minimum-stability']);
}
if (isset($config['repositories'])) { if (isset($config['repositories'])) {
foreach ($config['repositories'] as $index => $repo) { foreach ($config['repositories'] as $index => $repo) {
if (isset($repo['packagist']) && $repo['packagist'] === false) { if (isset($repo['packagist']) && $repo['packagist'] === false) {

View File

@ -48,6 +48,8 @@ class MemoryPackage extends BasePackage
protected $prettyAlias; protected $prettyAlias;
protected $dev; protected $dev;
protected $minimumStability = 'dev';
protected $requires = array(); protected $requires = array();
protected $conflicts = array(); protected $conflicts = array();
protected $provides = array(); protected $provides = array();
@ -597,6 +599,24 @@ class MemoryPackage extends BasePackage
return $this->homepage; return $this->homepage;
} }
/**
* Set the minimumStability
*
* @param string $minimumStability
*/
public function setMinimumStability($minimumStability)
{
$this->minimumStability = $minimumStability;
}
/**
* {@inheritDoc}
*/
public function getMinimumStability()
{
return $this->minimumStability;
}
/** /**
* Set the autoload mapping * Set the autoload mapping
* *