1
0
Fork 0

Merge pull request #3982 from Seldaek/prioritize-repos-over-versions

Prioritize repository over package versions in the default policy
pull/3882/merge
Jordi Boggiano 2015-04-30 11:04:17 +01:00
commit 6d76142907
3 changed files with 39 additions and 9 deletions

View File

@ -12,6 +12,13 @@ resulting order in which the solver will try to install them.
The rules are to be applied in the order of these descriptions.
### Repository priorities
Packages Repo1.Av1, Repo2.Av1
* priority(Repo1) >= priority(Repo2) => (Repo1.Av1, Repo2.Av1)
* priority(Repo1) < priority(Repo2) => (Repo2.Av1, Repo1.Av1)
### Package versions
Packages: Av1, Av2, Av3
@ -22,13 +29,6 @@ Request: install A
* (Av3)
### Repository priorities
Packages Repo1.Av1, Repo2.Av1
* priority(Repo1) >= priority(Repo2) => (Repo1.Av1, Repo2.Av1)
* priority(Repo1) < priority(Repo2) => (Repo2.Av1, Repo1.Av1)
### Virtual Packages (provides)
Packages Av1, Bv1

View File

@ -82,10 +82,10 @@ class DefaultPolicy implements PolicyInterface
}
foreach ($packages as &$literals) {
$literals = $this->pruneToBestVersion($pool, $literals);
$literals = $this->pruneToHighestPriorityOrInstalled($pool, $installedMap, $literals);
$literals = $this->pruneToBestVersion($pool, $literals);
$literals = $this->pruneRemoteAliases($pool, $literals);
}

View File

@ -0,0 +1,30 @@
--TEST--
Install prefers higher priority repositories over higher priority package versions
--COMPOSER--
{
"repositories": [
{
"type": "package",
"package": [
{ "name": "a/a", "version": "1.0.0" }
]
},
{
"type": "package",
"package": [
{ "name": "a/a", "version": "1.1.0" },
{ "name": "b/b", "version": "1.1.0" },
{ "name": "b/b", "version": "1.0.0" }
]
}
],
"require": {
"a/a": "*",
"b/b": "*"
}
}
--RUN--
install
--EXPECT--
Installing a/a (1.0.0)
Installing b/b (1.1.0)